mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 19:38:12 +00:00
LibWeb: Add support for the options variant of {add,remove}EventListener
This also adds a variant of {add,remove}_event_listener called {add,remove}_event_listener_with_options. This is used internally to perform {add,remove}_event_listener with a default constructed options struct. It was done like this because default constructing the Variant with the options struct requires the struct defintions to be present, which requires us to include AbortSignal.h, which would cause a circular include as AbortSignal.h includes EventTarget.h.
This commit is contained in:
parent
0e6c7eea0f
commit
3479f1c4e8
6 changed files with 121 additions and 22 deletions
|
@ -71,7 +71,7 @@ void MediaQueryList::add_listener(RefPtr<DOM::IDLEventListener> listener)
|
|||
// callback set to listener, and capture set to false, unless there already is an event listener
|
||||
// in that list with the same type, callback, and capture.
|
||||
// (NOTE: capture is set to false by default)
|
||||
add_event_listener(HTML::EventNames::change, listener);
|
||||
add_event_listener_without_options(HTML::EventNames::change, listener);
|
||||
}
|
||||
|
||||
// https://www.w3.org/TR/cssom-view/#dom-mediaquerylist-removelistener
|
||||
|
@ -80,7 +80,7 @@ void MediaQueryList::remove_listener(RefPtr<DOM::IDLEventListener> listener)
|
|||
// 1. Remove an event listener from the associated list of event listeners, whose type is change, callback is listener, and capture is false.
|
||||
// NOTE: While the spec doesn't technically use remove_event_listener and instead manipulates the list directly, every major engine uses remove_event_listener.
|
||||
// This means if an event listener removes another event listener that comes after it, the removed event listener will not be invoked.
|
||||
remove_event_listener(HTML::EventNames::change, listener);
|
||||
remove_event_listener_without_options(HTML::EventNames::change, listener);
|
||||
}
|
||||
|
||||
void MediaQueryList::set_onchange(Optional<Bindings::CallbackType> event_handler)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue