LibWeb/DOM: Copy document's allow declarative shadow roots when cloning

Corresponds to 77920094a4
This commit is contained in:
Sam Atkins 2025-07-08 14:13:44 +01:00 committed by Tim Ledbetter
commit a424a06d45
Notes: github-actions[bot] 2025-07-08 16:10:00 +00:00
4 changed files with 25 additions and 1 deletions

View file

@ -1446,13 +1446,15 @@ WebIDL::ExceptionOr<GC::Ref<Node>> Node::clone_single_node(Document& document) c
} }
}(); }();
// Set copys encoding, content type, URL, origin, type, and mode to those of node. // Set copys encoding, content type, URL, origin, type, mode, allow declarative shadow roots, and custom element registry to those of node.
document_copy->set_encoding(document_.encoding()); document_copy->set_encoding(document_.encoding());
document_copy->set_content_type(document_.content_type()); document_copy->set_content_type(document_.content_type());
document_copy->set_url(document_.url()); document_copy->set_url(document_.url());
document_copy->set_origin(document_.origin()); document_copy->set_origin(document_.origin());
document_copy->set_document_type(document_.document_type()); document_copy->set_document_type(document_.document_type());
document_copy->set_quirks_mode(document_.mode()); document_copy->set_quirks_mode(document_.mode());
document_copy->set_allow_declarative_shadow_roots(document_.allow_declarative_shadow_roots());
// FIXME: Custom element registry.
copy = move(document_copy); copy = move(document_copy);
} else if (is_document_type()) { } else if (is_document_type()) {
// -> DocumentType // -> DocumentType

View file

@ -0,0 +1,6 @@
Harness status: OK
Found 1 tests
1 Pass
Pass cloneNode() and document's allow declarative shadow roots

View file

@ -0,0 +1,8 @@
<!doctype html>
<meta charset=utf-8>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<div id=log></div>
<script src="../../dom/nodes/Node-cloneNode-document-allow-declarative-shadow-roots.window.js"></script>

View file

@ -0,0 +1,8 @@
"use strict";
test(() => {
const doc = document.cloneNode(document);
doc.write('<div><template shadowrootmode=open>test</template></div>');
assert_true(!!doc.body.firstChild.shadowRoot);
assert_equals(doc.body.firstChild.shadowRoot.textContent, "test");
}, "cloneNode() and document's allow declarative shadow roots");