LibWeb: Don't match the root node of HTMLCollection

Every user of HTMLCollection does not expect the root node to be a
potential match, so let's avoid it by using non-inclusive sub-tree
traversal. This avoids matching the element that getElementsByTagName
was called on for example, which is required by Ruffle:
da689b7687/web/packages/core/src/ruffle-object.ts (L321-L329)
This commit is contained in:
Luke Wilde 2023-04-13 15:51:09 +01:00 committed by Linus Groh
parent f80c05424e
commit 2125464b76
Notes: sideshowbarker 2024-07-17 02:55:44 +09:00

View file

@ -44,7 +44,7 @@ void HTMLCollection::visit_edges(Cell::Visitor& visitor)
JS::MarkedVector<Element*> HTMLCollection::collect_matching_elements() const
{
JS::MarkedVector<Element*> elements(m_root->heap());
m_root->for_each_in_inclusive_subtree_of_type<Element>([&](auto& element) {
m_root->for_each_in_subtree_of_type<Element>([&](auto& element) {
if (m_filter(element))
elements.append(const_cast<Element*>(&element));
return IterationDecision::Continue;