mirror of
https://github.com/fergalmoran/ladybird.git
synced 2025-12-29 21:00:06 +00:00
LibWeb: Implement EventTarget.dispatchEvent
Used by Web Platform Tests to test events
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
*/
|
||||
|
||||
#include <LibWeb/Bindings/ScriptExecutionContext.h>
|
||||
#include <LibWeb/DOM/Event.h>
|
||||
#include <LibWeb/DOM/EventListener.h>
|
||||
#include <LibWeb/DOM/EventTarget.h>
|
||||
|
||||
@@ -53,4 +54,18 @@ void EventTarget::remove_from_event_listener_list(NonnullRefPtr<EventListener> l
|
||||
});
|
||||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#dom-eventtarget-dispatchevent
|
||||
ExceptionOr<bool> EventTarget::dispatch_event_binding(NonnullRefPtr<Event> event)
|
||||
{
|
||||
if (event->dispatched())
|
||||
return DOM::InvalidStateError::create("The event is already being dispatched.");
|
||||
|
||||
if (!event->initialized())
|
||||
return DOM::InvalidStateError::create("Cannot dispatch an uninitialized event.");
|
||||
|
||||
event->set_is_trusted(false);
|
||||
|
||||
return dispatch_event(event);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user