LibWeb: Do not pass JS::Handle into NativeFunction callback captures

NativeFunction uses JS::HeapFunction for the callback so GC-allocated
captures will be visited anyway.
This commit is contained in:
Aliaksandr Kalenik 2023-09-26 16:47:29 +02:00 committed by Andreas Kling
parent 90aaa8ab40
commit 3bcd368703
Notes: sideshowbarker 2024-07-18 03:20:18 +09:00

View File

@ -561,7 +561,7 @@ void EventTarget::activate_event_handler(FlyString const& name, HTML::EventHandl
// location.reload();
// The body element is no longer in the DOM and there is no variable holding onto it. However, the onunload handler is still called, meaning the callback keeps the body element alive.
auto callback_function = JS::NativeFunction::create(
realm, [event_target = JS::make_handle(*this), name](JS::VM& vm) mutable -> JS::ThrowCompletionOr<JS::Value> {
realm, [event_target = this, name](JS::VM& vm) mutable -> JS::ThrowCompletionOr<JS::Value> {
// The event dispatcher should only call this with one argument.
VERIFY(vm.argument_count() == 1);