mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 05:47:35 +00:00
LibWeb: Fix crash when removing event listeners
This commit is contained in:
parent
27eb70cbba
commit
9b9d32dfb2
1 changed files with 8 additions and 1 deletions
|
@ -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,
|
// 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.
|
// 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) {
|
auto it = m_event_listener_list.find_if([&](auto& entry) {
|
||||||
return entry->type == type
|
return entry->type == type
|
||||||
&& entry->callback->callback().callback.cell() == callback->callback().callback.cell()
|
&& callbacks_match(entry)
|
||||||
&& entry->capture == capture;
|
&& entry->capture == capture;
|
||||||
});
|
});
|
||||||
if (it != m_event_listener_list.end())
|
if (it != m_event_listener_list.end())
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue