summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibWeb/DOM/EventTarget.h
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2021-01-18 12:15:02 +0100
committerAndreas Kling <kling@serenityos.org>2021-01-18 12:18:29 +0100
commit0639e778986877ef0a6883eb9011ad8b4f56b642 (patch)
tree32afd1a67fa823a59d25e4181c3503471b63c8f6 /Userland/Libraries/LibWeb/DOM/EventTarget.h
parentfd83918476dd4d91a07df44c831275f0b5cdd7e9 (diff)
downloadserenity-0639e778986877ef0a6883eb9011ad8b4f56b642.zip
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.
Diffstat (limited to 'Userland/Libraries/LibWeb/DOM/EventTarget.h')
-rw-r--r--Userland/Libraries/LibWeb/DOM/EventTarget.h2
1 files changed, 1 insertions, 1 deletions
diff --git a/Userland/Libraries/LibWeb/DOM/EventTarget.h b/Userland/Libraries/LibWeb/DOM/EventTarget.h
index 32399a6a7a..f03d4a4fb2 100644
--- a/Userland/Libraries/LibWeb/DOM/EventTarget.h
+++ b/Userland/Libraries/LibWeb/DOM/EventTarget.h
@@ -51,7 +51,7 @@ public:
void remove_from_event_listener_list(NonnullRefPtr<EventListener>);
virtual bool dispatch_event(NonnullRefPtr<Event>) = 0;
- virtual Bindings::EventTargetWrapper* create_wrapper(JS::GlobalObject&) = 0;
+ virtual JS::Object* create_wrapper(JS::GlobalObject&) = 0;
Bindings::ScriptExecutionContext* script_execution_context() { return m_script_execution_context; }
virtual EventTarget* get_parent(const Event&) { return nullptr; }