1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 14:17:36 +00:00

LibWeb: Support "useCapture" parameter to add/removeEventListener

This is not a complete implementation of API, since we're also supposed
to accept an options dictionary as the third argument. However, a lot of
web content uses the boolean variant, and it's trivial to support.
This commit is contained in:
Andreas Kling 2022-02-16 22:15:17 +01:00
parent e76e8e22b5
commit 9521f71944
3 changed files with 8 additions and 8 deletions

View file

@ -46,10 +46,10 @@ EventTarget::~EventTarget()
}
// https://dom.spec.whatwg.org/#dom-eventtarget-addeventlistener
void EventTarget::add_event_listener(FlyString const& type, RefPtr<IDLEventListener> callback)
void EventTarget::add_event_listener(FlyString const& type, RefPtr<IDLEventListener> callback, bool use_capture)
{
// FIXME: 1. Let capture, passive, once, and signal be the result of flattening more options.
bool capture = false;
bool capture = use_capture;
bool passive = false;
bool once = false;
RefPtr<AbortSignal> signal = nullptr;
@ -96,10 +96,10 @@ void EventTarget::add_an_event_listener(NonnullRefPtr<DOMEventListener> listener
}
// https://dom.spec.whatwg.org/#dom-eventtarget-removeeventlistener
void EventTarget::remove_event_listener(FlyString const& type, RefPtr<IDLEventListener> callback)
void EventTarget::remove_event_listener(FlyString const& type, RefPtr<IDLEventListener> callback, bool use_capture)
{
// FIXME: 1. Let capture be the result of flattening options.
bool capture = false;
bool capture = use_capture;
// 2. If thiss event listener list contains an event listener whose type is type, callback is callback, and capture is capture,
// then remove an event listener with this and that event listener.