mirror of
				https://github.com/LadybirdBrowser/ladybird.git
				synced 2025-10-25 09:30:01 +00:00 
			
		
		
		
	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.
		
			
				
	
	
		
			31 lines
		
	
	
	
		
			1.3 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			31 lines
		
	
	
	
		
			1.3 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
| /*
 | |
|  * Copyright (c) 2021, Andreas Kling <kling@serenityos.org>
 | |
|  *
 | |
|  * SPDX-License-Identifier: BSD-2-Clause
 | |
|  */
 | |
| 
 | |
| #include <LibWeb/DOM/EventTarget.h>
 | |
| #include <LibWeb/HTML/EventNames.h>
 | |
| #include <LibWeb/HTML/GlobalEventHandlers.h>
 | |
| #include <LibWeb/UIEvents/EventNames.h>
 | |
| 
 | |
| namespace Web::HTML {
 | |
| 
 | |
| #undef __ENUMERATE
 | |
| #define __ENUMERATE(attribute_name, event_name)                                    \
 | |
|     void GlobalEventHandlers::set_##attribute_name(WebIDL::CallbackType* value)    \
 | |
|     {                                                                              \
 | |
|         if (auto event_target = global_event_handlers_to_event_target(event_name)) \
 | |
|             event_target->set_event_handler_attribute(event_name, value);          \
 | |
|     }                                                                              \
 | |
|     WebIDL::CallbackType* GlobalEventHandlers::attribute_name()                    \
 | |
|     {                                                                              \
 | |
|         if (auto event_target = global_event_handlers_to_event_target(event_name)) \
 | |
|             return event_target->event_handler_attribute(event_name);              \
 | |
|         return nullptr;                                                            \
 | |
|     }
 | |
| ENUMERATE_GLOBAL_EVENT_HANDLERS(__ENUMERATE)
 | |
| #undef __ENUMERATE
 | |
| 
 | |
| GlobalEventHandlers::~GlobalEventHandlers() = default;
 | |
| }
 |