Ver Fonte

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.
Aliaksandr Kalenik há 1 ano atrás
pai
commit
3bcd368703
1 ficheiros alterados com 1 adições e 1 exclusões
  1. 1 1
      Userland/Libraries/LibWeb/DOM/EventTarget.cpp

+ 1 - 1
Userland/Libraries/LibWeb/DOM/EventTarget.cpp

@@ -561,7 +561,7 @@ void EventTarget::activate_event_handler(FlyString const& name, HTML::EventHandl
     //          location.reload();
     //          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.
     //       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(
     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.
             // The event dispatcher should only call this with one argument.
             VERIFY(vm.argument_count() == 1);
             VERIFY(vm.argument_count() == 1);