1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 08:47:44 +00:00

LibWeb: Visit IntersectionObserverRegistration instead of using Handle

This fixes GC-leak caused by JS::Handle<IntersectionObserverver>
preventing an element that owns the handle from being deallocated.
This commit is contained in:
Aliaksandr Kalenik 2023-09-26 16:54:39 +02:00 committed by Andreas Kling
parent ac5c4705fd
commit 35623ad52e
3 changed files with 4 additions and 2 deletions

View file

@ -92,7 +92,7 @@ void IntersectionObserver::observe(DOM::Element& target)
// property set to observer, a previousThresholdIndex property set to -1, and a previousIsIntersecting
// property set to false.
auto intersection_observer_registration = IntersectionObserverRegistration {
.observer = JS::make_handle(*this),
.observer = *this,
.previous_threshold_index = OptionalNone {},
.previous_is_intersecting = false,
};

View file

@ -23,7 +23,7 @@ struct IntersectionObserverInit {
struct IntersectionObserverRegistration {
// https://www.w3.org/TR/intersection-observer/#dom-intersectionobserverregistration-observer
// [A]n observer property holding an IntersectionObserver.
JS::Handle<IntersectionObserver> observer;
JS::NonnullGCPtr<IntersectionObserver> observer;
// https://www.w3.org/TR/intersection-observer/#dom-intersectionobserverregistration-observer
// NOTE: Optional is used in place of the spec using -1 to indicate no previous index.