mirror of
https://github.com/RGBCube/serenity
synced 2025-05-28 21:45:09 +00:00
LibWeb: Make Node.childNodes vend the same NodeList every time
This commit is contained in:
parent
4814e1bd65
commit
a5bb30d2ba
2 changed files with 9 additions and 5 deletions
|
@ -90,6 +90,7 @@ void Node::visit_edges(Cell::Visitor& visitor)
|
||||||
visitor.visit(m_last_child.ptr());
|
visitor.visit(m_last_child.ptr());
|
||||||
visitor.visit(m_next_sibling.ptr());
|
visitor.visit(m_next_sibling.ptr());
|
||||||
visitor.visit(m_previous_sibling.ptr());
|
visitor.visit(m_previous_sibling.ptr());
|
||||||
|
visitor.visit(m_child_nodes);
|
||||||
|
|
||||||
for (auto& registered_observer : m_registered_observer_list)
|
for (auto& registered_observer : m_registered_observer_list)
|
||||||
visitor.visit(registered_observer);
|
visitor.visit(registered_observer);
|
||||||
|
@ -861,11 +862,12 @@ ParentNode* Node::parent_or_shadow_host()
|
||||||
|
|
||||||
JS::NonnullGCPtr<NodeList> Node::child_nodes()
|
JS::NonnullGCPtr<NodeList> Node::child_nodes()
|
||||||
{
|
{
|
||||||
// FIXME: This should return the same LiveNodeList object every time,
|
if (!m_child_nodes) {
|
||||||
// but that would cause a reference cycle since NodeList refs the root.
|
m_child_nodes = LiveNodeList::create(window(), *this, [this](auto& node) {
|
||||||
return LiveNodeList::create(window(), *this, [this](auto& node) {
|
return is_parent_of(node);
|
||||||
return is_parent_of(node);
|
});
|
||||||
});
|
}
|
||||||
|
return *m_child_nodes;
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector<JS::Handle<Node>> Node::children_as_vector() const
|
Vector<JS::Handle<Node>> Node::children_as_vector() const
|
||||||
|
|
|
@ -648,6 +648,8 @@ private:
|
||||||
JS::GCPtr<Node> m_last_child;
|
JS::GCPtr<Node> m_last_child;
|
||||||
JS::GCPtr<Node> m_next_sibling;
|
JS::GCPtr<Node> m_next_sibling;
|
||||||
JS::GCPtr<Node> m_previous_sibling;
|
JS::GCPtr<Node> m_previous_sibling;
|
||||||
|
|
||||||
|
JS::GCPtr<NodeList> m_child_nodes;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue