Skip to content

Commit 4e262b0

Browse files
committed
A clonable ShadowRoot is always cloned
https://bugs.webkit.org/show_bug.cgi?id=272089 Reviewed by Ryosuke Niwa. This aligns us with other browsers and this change to the DOM standard: whatwg/dom#1272 * LayoutTests/imported/w3c/web-platform-tests/shadow-dom/shadow-root-clonable-expected.txt: * Source/WebCore/dom/Element.cpp: (WebCore::Element::cloneNodeInternal): This is the change that makes the test pass. * Source/WebCore/dom/ShadowRoot.cpp: (WebCore::ShadowRoot::cloneNodeInternal): This cleans up a conditional that is always true. Canonical link: https://commits.webkit.org/277066@main
1 parent 4ab8a90 commit 4e262b0

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

LayoutTests/imported/w3c/web-platform-tests/shadow-dom/shadow-root-clonable-expected.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
FAIL attachShadow with clonable: true null is not an object (evaluating 'shallowClonedRoot.clonable')
2+
PASS attachShadow with clonable: true
33
PASS attachShadow with clonable: false
44
PASS attachShadow with clonable: undefined
55
PASS declarative shadow roots do *not* get clonable: true automatically

Source/WebCore/dom/Element.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -579,7 +579,6 @@ Ref<Node> Element::cloneNodeInternal(Document& targetDocument, CloningOperation
579579
{
580580
switch (type) {
581581
case CloningOperation::OnlySelf:
582-
return cloneElementWithoutChildren(targetDocument);
583582
case CloningOperation::SelfWithTemplateContent: {
584583
Ref clone = cloneElementWithoutChildren(targetDocument);
585584
ScriptDisallowedScope::EventAllowedScope eventAllowedScope { clone };

Source/WebCore/dom/ShadowRoot.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -236,10 +236,11 @@ bool ShadowRoot::childTypeAllowed(NodeType type) const
236236
Ref<Node> ShadowRoot::cloneNodeInternal(Document& targetDocument, CloningOperation type)
237237
{
238238
RELEASE_ASSERT(m_mode != ShadowRootMode::UserAgent);
239+
ASSERT(m_isClonable);
239240
switch (type) {
240241
case CloningOperation::SelfWithTemplateContent:
241242
return create(targetDocument, m_mode, m_slotAssignmentMode, m_delegatesFocus ? DelegatesFocus::Yes : DelegatesFocus::No,
242-
m_isClonable ? Clonable::Yes : Clonable::No, m_availableToElementInternals ? AvailableToElementInternals::Yes : AvailableToElementInternals::No);
243+
Clonable::Yes, m_availableToElementInternals ? AvailableToElementInternals::Yes : AvailableToElementInternals::No);
243244
case CloningOperation::OnlySelf:
244245
case CloningOperation::Everything:
245246
break;

0 commit comments

Comments
 (0)