Skip to content

Truly independent web browser

LibWeb: Always clone the whole tree of a clonable shadow root

Andreas Kling3eef72c5b549
diff --git a/Libraries/LibWeb/DOM/Node.cpp b/Libraries/LibWeb/DOM/Node.cpp
index 5600439d742..80ef5a620ab 100644
--- a/Libraries/LibWeb/DOM/Node.cpp
+++ b/Libraries/LibWeb/DOM/Node.cpp
@@ -1948,11 +1948,10 @@ WebIDL::ExceptionOr<GC::Ref<Node>> Node::clone_node(GC::Ptr<Document> document,
// registry null.
copy_element.shadow_root()->set_keep_custom_element_registry_null(node_element->shadow_root()->keep_custom_element_registry_null());
- // 7. For each child of node’s shadow root’s children, in tree order:
- // clone a node given child with document set to document, subtree set to subtree, and parent set to copy’s
- // shadow root.
+ // 7. For each child of node’s shadow root’s children, in tree order: clone a node given child with document set
+ // to document, subtree set to true, and parent set to copy’s shadow root.
for (auto child = node_element->shadow_root()->first_child(); child; child = child->next_sibling()) {
- TRY(child->clone_node(document, subtree, copy_element.shadow_root()));
+ TRY(child->clone_node(document, true, copy_element.shadow_root()));
}
}
diff --git a/Tests/LibWeb/Text/expected/wpt-import/shadow-dom/shadow-root-clonable.txt b/Tests/LibWeb/Text/expected/wpt-import/shadow-dom/shadow-root-clonable.txt
index a413258a403..64f7dce4148 100644
--- a/Tests/LibWeb/Text/expected/wpt-import/shadow-dom/shadow-root-clonable.txt
+++ b/Tests/LibWeb/Text/expected/wpt-import/shadow-dom/shadow-root-clonable.txt
@@ -2,9 +2,8 @@ Harness status: OK
Found 6 tests
-5 Pass
-1 Fail
-Fail attachShadow with clonable: true
+6 Pass
+Pass attachShadow with clonable: true
Pass attachShadow with clonable: false
Pass attachShadow with clonable: undefined
Pass declarative shadow roots do *not* get clonable: true automatically