LibWeb: Add EventTarget.removeEventListener()
This commit is contained in:
parent
d724a12732
commit
244b243d22
Notes:
sideshowbarker
2024-07-19 05:29:39 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/244b243d22d
3 changed files with 9 additions and 0 deletions
|
@ -42,4 +42,11 @@ void EventTarget::add_event_listener(const FlyString& event_name, NonnullRefPtr<
|
|||
m_listeners.append({ event_name, move(listener) });
|
||||
}
|
||||
|
||||
void EventTarget::remove_event_listener(const FlyString& event_name, NonnullRefPtr<EventListener> listener)
|
||||
{
|
||||
m_listeners.remove_first_matching([&](auto& entry) {
|
||||
return entry.event_name == event_name && &entry.listener->function() == &listener->function();
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -44,6 +44,7 @@ public:
|
|||
void unref() { unref_event_target(); }
|
||||
|
||||
void add_event_listener(const FlyString& event_name, NonnullRefPtr<EventListener>);
|
||||
void remove_event_listener(const FlyString& event_name, NonnullRefPtr<EventListener>);
|
||||
|
||||
virtual void dispatch_event(NonnullRefPtr<Event>) = 0;
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
interface EventTarget {
|
||||
|
||||
void addEventListener(DOMString type, EventListener? callback);
|
||||
void removeEventListener(DOMString type, EventListener? callback);
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue