diff options
Diffstat (limited to 'Userland/Libraries/LibWeb/DOM/EventTarget.cpp')
-rw-r--r-- | Userland/Libraries/LibWeb/DOM/EventTarget.cpp | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/Userland/Libraries/LibWeb/DOM/EventTarget.cpp b/Userland/Libraries/LibWeb/DOM/EventTarget.cpp index 021a5d7199..2a2e113a03 100644 --- a/Userland/Libraries/LibWeb/DOM/EventTarget.cpp +++ b/Userland/Libraries/LibWeb/DOM/EventTarget.cpp @@ -163,9 +163,16 @@ void EventTarget::remove_event_listener(FlyString const& type, RefPtr<IDLEventLi // 2. If thisโs 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. + auto callbacks_match = [&](NonnullRefPtr<DOMEventListener>& entry) { + if (entry->callback.is_null() && callback.is_null()) + return true; + if (entry->callback.is_null() || callback.is_null()) + return false; + return entry->callback->callback().callback.cell() == callback->callback().callback.cell(); + }; auto it = m_event_listener_list.find_if([&](auto& entry) { return entry->type == type - && entry->callback->callback().callback.cell() == callback->callback().callback.cell() + && callbacks_match(entry) && entry->capture == capture; }); if (it != m_event_listener_list.end()) |