mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-05-03 04:52:06 +02:00
LibWeb: Unregister IntersectionObserver from registration document
Before this change, there was some confusion possible where an IO would try to find its way back to the document where we registered it. This led to an assertion failure in the test I'm adding in the next commit, so let's fix this first. IOs now (weakly) remember the document where they are registered, and only unregister from there.
This commit is contained in:
Notes:
sideshowbarker
2024-07-17 02:55:44 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/21d9da0f3b Pull-request: https://github.com/SerenityOS/serenity/pull/22024 Issue: https://github.com/SerenityOS/serenity/issues/22020
@@ -53,17 +53,17 @@ IntersectionObserver::IntersectionObserver(JS::Realm& realm, JS::GCPtr<WebIDL::C
|
||||
, m_thresholds(move(thresholds))
|
||||
{
|
||||
intersection_root().visit([this](auto& node) {
|
||||
node->document().register_intersection_observer({}, *this);
|
||||
m_document = node->document();
|
||||
});
|
||||
m_document->register_intersection_observer({}, *this);
|
||||
}
|
||||
|
||||
IntersectionObserver::~IntersectionObserver() = default;
|
||||
|
||||
void IntersectionObserver::finalize()
|
||||
{
|
||||
intersection_root().visit([this](auto& node) {
|
||||
node->document().unregister_intersection_observer({}, *this);
|
||||
});
|
||||
if (m_document)
|
||||
m_document->unregister_intersection_observer({}, *this);
|
||||
}
|
||||
|
||||
void IntersectionObserver::initialize(JS::Realm& realm)
|
||||
|
||||
Reference in New Issue
Block a user