mirror of
https://github.com/RGBCube/serenity
synced 2025-07-24 17:47:43 +00:00
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.
This commit is contained in:
parent
a45ba638a7
commit
ac98a48177
1 changed files with 4 additions and 1 deletions
|
@ -27,6 +27,8 @@
|
||||||
#include <LibJS/Runtime/Function.h>
|
#include <LibJS/Runtime/Function.h>
|
||||||
#include <LibWeb/Bindings/EventTargetWrapper.h>
|
#include <LibWeb/Bindings/EventTargetWrapper.h>
|
||||||
#include <LibWeb/Bindings/EventTargetWrapperFactory.h>
|
#include <LibWeb/Bindings/EventTargetWrapperFactory.h>
|
||||||
|
#include <LibWeb/Bindings/EventWrapper.h>
|
||||||
|
#include <LibWeb/Bindings/EventWrapperFactory.h>
|
||||||
#include <LibWeb/Bindings/ScriptExecutionContext.h>
|
#include <LibWeb/Bindings/ScriptExecutionContext.h>
|
||||||
#include <LibWeb/DOM/Event.h>
|
#include <LibWeb/DOM/Event.h>
|
||||||
#include <LibWeb/DOM/EventDispatcher.h>
|
#include <LibWeb/DOM/EventDispatcher.h>
|
||||||
|
@ -44,9 +46,10 @@ void EventDispatcher::dispatch(EventTarget& target, NonnullRefPtr<Event> event)
|
||||||
auto& function = listener.listener->function();
|
auto& function = listener.listener->function();
|
||||||
auto& global_object = function.global_object();
|
auto& global_object = function.global_object();
|
||||||
auto* this_value = Bindings::wrap(global_object, target);
|
auto* this_value = Bindings::wrap(global_object, target);
|
||||||
|
auto* wrapped_event = Bindings::wrap(global_object, *event);
|
||||||
|
|
||||||
auto& vm = global_object.vm();
|
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())
|
if (vm.exception())
|
||||||
vm.clear_exception();
|
vm.clear_exception();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue