mirror of
https://github.com/SerenityOS/serenity
synced 2026-05-05 06:32:26 +02:00
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:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user