mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 05:58:11 +00:00
LibWeb: Don't assume IO.unobserve() called on observed element
It's perfectly possible for JavaScript to call unobserve() on an element that hasn't been observed. Let's stop asserting if that happens. :^) Fixes #22020
This commit is contained in:
parent
21d9da0f3b
commit
ef809eea1e
3 changed files with 13 additions and 1 deletions
|
@ -0,0 +1 @@
|
||||||
|
PASS! (Didn't crash)
|
|
@ -0,0 +1,10 @@
|
||||||
|
<body>
|
||||||
|
<script src="../include.js"></script>
|
||||||
|
<script>
|
||||||
|
test(() => {
|
||||||
|
let observer = new IntersectionObserver(function() {});
|
||||||
|
let div = document.createElement("div");
|
||||||
|
observer.unobserve(div);
|
||||||
|
println("PASS! (Didn't crash)");
|
||||||
|
});
|
||||||
|
</script>
|
|
@ -2086,7 +2086,8 @@ void Element::register_intersection_observer(Badge<IntersectionObserver::Interse
|
||||||
|
|
||||||
void Element::unregister_intersection_observer(Badge<IntersectionObserver::IntersectionObserver>, JS::NonnullGCPtr<IntersectionObserver::IntersectionObserver> observer)
|
void Element::unregister_intersection_observer(Badge<IntersectionObserver::IntersectionObserver>, JS::NonnullGCPtr<IntersectionObserver::IntersectionObserver> observer)
|
||||||
{
|
{
|
||||||
VERIFY(m_registered_intersection_observers);
|
if (!m_registered_intersection_observers)
|
||||||
|
return;
|
||||||
m_registered_intersection_observers->remove_first_matching([&observer](IntersectionObserver::IntersectionObserverRegistration const& entry) {
|
m_registered_intersection_observers->remove_first_matching([&observer](IntersectionObserver::IntersectionObserverRegistration const& entry) {
|
||||||
return entry.observer == observer;
|
return entry.observer == observer;
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue