summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLinus Groh <mail@linusgroh.de>2020-10-15 20:02:28 +0200
committerAndreas Kling <kling@serenityos.org>2020-10-15 20:40:35 +0200
commitac98a48177bd8b628a8eb29d1f719df4468b22a0 (patch)
tree52e93f090d0119262cbc9f5b52502d7c032ed073
parenta45ba638a77127ea03aaeedc9e7ab07e65910703 (diff)
downloadserenity-ac98a48177bd8b628a8eb29d1f719df4468b22a0.zip
LibWeb: Fix EventDispatcher::dispatch()
We were never wrapping and using the actual DOM::Event but instead wrapped the *target* twice and passed it to the event listener callback, as this value and as argument. This unbreaks "fun demo" and "canvas path quadratic curve test" - and event dispatching in general, of course :^) Fixes #3721.
-rw-r--r--Libraries/LibWeb/DOM/EventDispatcher.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/Libraries/LibWeb/DOM/EventDispatcher.cpp b/Libraries/LibWeb/DOM/EventDispatcher.cpp
index eb3e212db9..173fef805f 100644
--- a/Libraries/LibWeb/DOM/EventDispatcher.cpp
+++ b/Libraries/LibWeb/DOM/EventDispatcher.cpp
@@ -27,6 +27,8 @@
#include <LibJS/Runtime/Function.h>
#include <LibWeb/Bindings/EventTargetWrapper.h>
#include <LibWeb/Bindings/EventTargetWrapperFactory.h>
+#include <LibWeb/Bindings/EventWrapper.h>
+#include <LibWeb/Bindings/EventWrapperFactory.h>
#include <LibWeb/Bindings/ScriptExecutionContext.h>
#include <LibWeb/DOM/Event.h>
#include <LibWeb/DOM/EventDispatcher.h>
@@ -44,9 +46,10 @@ void EventDispatcher::dispatch(EventTarget& target, NonnullRefPtr<Event> event)
auto& function = listener.listener->function();
auto& global_object = function.global_object();
auto* this_value = Bindings::wrap(global_object, target);
+ auto* wrapped_event = Bindings::wrap(global_object, *event);
auto& vm = global_object.vm();
- (void)vm.call(function, this_value, Bindings::wrap(global_object, target));
+ (void)vm.call(function, this_value, wrapped_event);
if (vm.exception())
vm.clear_exception();
}