mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 20:47:45 +00:00
LibWeb: Convert DOM::AbortSignal to use JS::SafeFunction
This protects the captured GC pointers automatically instead of manually.
This commit is contained in:
parent
67e396d931
commit
07e3bb729d
3 changed files with 6 additions and 5 deletions
|
@ -170,9 +170,10 @@ void EventTarget::add_an_event_listener(DOMEventListener& listener)
|
|||
|
||||
// 5. If listener’s signal is not null, then add the following abort steps to it:
|
||||
if (listener.signal) {
|
||||
listener.signal->add_abort_algorithm([strong_event_target = JS::make_handle(*this), listener = JS::make_handle(&listener)]() mutable {
|
||||
// NOTE: `this` and `listener` are protected by AbortSignal using JS::SafeFunction.
|
||||
listener.signal->add_abort_algorithm([this, &listener]() mutable {
|
||||
// 1. Remove an event listener with eventTarget and listener.
|
||||
strong_event_target->remove_an_event_listener(*listener);
|
||||
remove_an_event_listener(listener);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue