mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 07:48:11 +00: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:
parent
57e2b5ef59
commit
21d9da0f3b
2 changed files with 7 additions and 4 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue