diff options
author | stelar7 <dudedbz@gmail.com> | 2022-04-20 00:00:08 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2022-04-20 14:07:38 +0200 |
commit | 62bd88dc1405989203268effb6f03a3bc8084ac1 (patch) | |
tree | 55c5fe82505a0d18ff519262e32f87b78afb5d0a /Userland | |
parent | 8055b0a9b9ad1d7fb8d71727459bb97a2d043c42 (diff) | |
download | serenity-62bd88dc1405989203268effb6f03a3bc8084ac1.zip |
LibWeb: Add spec comments to EventTarget
Diffstat (limited to 'Userland')
-rw-r--r-- | Userland/Libraries/LibWeb/DOM/EventTarget.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/Userland/Libraries/LibWeb/DOM/EventTarget.cpp b/Userland/Libraries/LibWeb/DOM/EventTarget.cpp index ae84bd87bb..a995a360b0 100644 --- a/Userland/Libraries/LibWeb/DOM/EventTarget.cpp +++ b/Userland/Libraries/LibWeb/DOM/EventTarget.cpp @@ -203,14 +203,17 @@ void EventTarget::remove_from_event_listener_list(DOMEventListener& listener) // https://dom.spec.whatwg.org/#dom-eventtarget-dispatchevent ExceptionOr<bool> EventTarget::dispatch_event_binding(NonnullRefPtr<Event> event) { + // 1. If event’s dispatch flag is set, or if its initialized flag is not set, then throw an "InvalidStateError" DOMException. 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."); + // 2. Initialize event’s isTrusted attribute to false. event->set_is_trusted(false); + // 3. Return the result of dispatching event to this. return dispatch_event(event); } @@ -269,7 +272,7 @@ static EventTarget* determine_target_of_event_handler(EventTarget& event_target, if (!event_target_element.document().is_active()) return nullptr; - // Return eventTarget's node document's relevant global object. + // 4. Return eventTarget's node document's relevant global object. return &event_target_element.document().window(); } |