mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-01-06 00:25:12 +00:00
LibWeb: Make the Window object "inherit" from EventTarget :^)
Since Web::Bindings::WindowObject inherits from JS::GlobalObject, it cannot also inherit from Web::Bindings::EventTargetWrapper. However, that's not actually necessary. Instead, we simply set the Window object's prototype to the EventTargetPrototype, and add a little extra branch in the impl_from() function that turns the JS "this" value into a DOM::EventTarget*. With this, you can now call window.addEventListener()! Very cool :^) Fixes #4758.
This commit is contained in:
@@ -65,7 +65,7 @@ bool Performance::dispatch_event(NonnullRefPtr<DOM::Event> event)
|
||||
return DOM::EventDispatcher::dispatch(*this, event);
|
||||
}
|
||||
|
||||
Bindings::EventTargetWrapper* Performance::create_wrapper(JS::GlobalObject& global_object)
|
||||
JS::Object* Performance::create_wrapper(JS::GlobalObject& global_object)
|
||||
{
|
||||
return Bindings::wrap(global_object, *this);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user