From 2125464b7641c03b1fac3a8f20a6085b4c4eae48 Mon Sep 17 00:00:00 2001 From: Luke Wilde Date: Thu, 13 Apr 2023 15:51:09 +0100 Subject: [PATCH] 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: https://github.com/ruffle-rs/ruffle/blob/da689b7687d6bb23f37251e902ccddabdfcc5f48/web/packages/core/src/ruffle-object.ts#L321-L329 --- Userland/Libraries/LibWeb/DOM/HTMLCollection.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Userland/Libraries/LibWeb/DOM/HTMLCollection.cpp b/Userland/Libraries/LibWeb/DOM/HTMLCollection.cpp index 098abb4924..106adb80b9 100644 --- a/Userland/Libraries/LibWeb/DOM/HTMLCollection.cpp +++ b/Userland/Libraries/LibWeb/DOM/HTMLCollection.cpp @@ -44,7 +44,7 @@ void HTMLCollection::visit_edges(Cell::Visitor& visitor) JS::MarkedVector HTMLCollection::collect_matching_elements() const { JS::MarkedVector elements(m_root->heap()); - m_root->for_each_in_inclusive_subtree_of_type([&](auto& element) { + m_root->for_each_in_subtree_of_type([&](auto& element) { if (m_filter(element)) elements.append(const_cast(&element)); return IterationDecision::Continue;