mirror of
https://github.com/RGBCube/serenity
synced 2025-05-18 21:45:08 +00:00
LibWeb: Ignore window-forwarded document.body.onfoo in detached DOM
Normally, assigning to e.g document.body.onload will forward to window.onload. However, in a detached DOM tree, there is no associated window, so we have nowhere to forward to, making this a no-op. The bulk of this change is making Document::window() return a nullable pointer, as documents created by DOMParser or DOMImplementation do not have an associated window object, and so must be able to return null from here.
This commit is contained in:
parent
7139d5945f
commit
b98a2be96b
28 changed files with 92 additions and 61 deletions
|
@ -11,14 +11,17 @@
|
|||
namespace Web::HTML {
|
||||
|
||||
#undef __ENUMERATE
|
||||
#define __ENUMERATE(attribute_name, event_name) \
|
||||
void WindowEventHandlers::set_##attribute_name(WebIDL::CallbackType* value) \
|
||||
{ \
|
||||
window_event_handlers_to_event_target().set_event_handler_attribute(event_name, value); \
|
||||
} \
|
||||
WebIDL::CallbackType* WindowEventHandlers::attribute_name() \
|
||||
{ \
|
||||
return window_event_handlers_to_event_target().event_handler_attribute(event_name); \
|
||||
#define __ENUMERATE(attribute_name, event_name) \
|
||||
void WindowEventHandlers::set_##attribute_name(WebIDL::CallbackType* value) \
|
||||
{ \
|
||||
if (auto event_target = window_event_handlers_to_event_target()) \
|
||||
event_target->set_event_handler_attribute(event_name, value); \
|
||||
} \
|
||||
WebIDL::CallbackType* WindowEventHandlers::attribute_name() \
|
||||
{ \
|
||||
if (auto event_target = window_event_handlers_to_event_target()) \
|
||||
return event_target->event_handler_attribute(event_name); \
|
||||
return nullptr; \
|
||||
}
|
||||
ENUMERATE_WINDOW_EVENT_HANDLERS(__ENUMERATE)
|
||||
#undef __ENUMERATE
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue