diff --git a/Userland/Libraries/LibWeb/DOM/EventTarget.cpp b/Userland/Libraries/LibWeb/DOM/EventTarget.cpp index 95c74d0090..ae84bd87bb 100644 --- a/Userland/Libraries/LibWeb/DOM/EventTarget.cpp +++ b/Userland/Libraries/LibWeb/DOM/EventTarget.cpp @@ -519,15 +519,18 @@ void EventTarget::activate_event_handler(FlyString const& name, HTML::EventHandl // returning the element's document's global object, which is the HTML::Window object. // For any other HTMLElement who just had an element attribute set, `this` will be that HTMLElement, so the global object is this's document's realm's global object. // For anything else, it came from JavaScript, so use the global object of the provided callback function. - // Sadly, this doesn't work if an element attribute is set on a
element before any script is run, as Window::wrapper() will be null. JS::GlobalObject* global_object = nullptr; if (is_attribute == IsAttribute::Yes) { if (is