cloneNode(true) does not clone nested template elements' contents
authorrniwa@webkit.org <rniwa@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 15 Dec 2014 22:19:38 +0000 (22:19 +0000)
committerrniwa@webkit.org <rniwa@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 15 Dec 2014 22:19:38 +0000 (22:19 +0000)
commitda5af9acc49fa0c9dd897866f9ea9e31f1a9a17b
treebe7ed04d13731d138c74bf008af2420c55ff52b0
parentc15e1aca34a3a452b47aa03e8eb447f02cb5dbd8
cloneNode(true) does not clone nested template elements' contents
https://bugs.webkit.org/show_bug.cgi?id=137755

Reviewed by Darin Adler.

Source/WebCore:

The bug was caused by cloneChildNodes not copying template element's content.

Fixed the bug by adding the third behavior (CloneContent) to the polymorphic
cloneNodeInternal, which copies template element's content but not its children,
in addition to the existing CloneSelf (deep=false) and CloneChildren (deep=true).

Test: fast/dom/HTMLTemplateElement/cloneNode-nested-templates.html

* dom/Attr.cpp:
(WebCore::Attr::cloneNodeInternal): Renamed from cloneNode.
* dom/Attr.h:
* dom/CDATASection.cpp:
(WebCore::CDATASection::cloneNodeInternal): Renamed from cloneNode.
* dom/CDATASection.h:
* dom/Comment.cpp:
(WebCore::Comment::cloneNodeInternal): Renamed from cloneNode.
* dom/Comment.h:
* dom/ContainerNode.cpp:
(WebCore::ContainerNode::cloneChildNodes): Calls cloneNode with CloneContent.
* dom/Document.cpp:
(WebCore::Document::cloneNodeInternal): Renamed from cloneNode.
* dom/Document.h:
* dom/DocumentFragment.cpp:
(WebCore::DocumentFragment::cloneNodeInternal): Renamed from cloneNode.
* dom/DocumentFragment.h:
* dom/DocumentType.cpp:
(WebCore::DocumentType::cloneNodeInternal): Renamed from cloneNode.
* dom/DocumentType.h:
* dom/Element.cpp:
(WebCore::Element::cloneNodeInternal): Renamed from cloneNode.
* dom/Element.h:
* dom/EntityReference.cpp:
(WebCore::EntityReference::cloneNodeInternal): Renamed from cloneNode.
* dom/EntityReference.h:
* dom/Node.h:
(WebCore::Node::cloneNode): Added. It calls cloneNodeInternal with CloneSelf or CloneChildren.
* dom/ProcessingInstruction.cpp:
(WebCore::ProcessingInstruction::cloneNodeInternal): Renamed from cloneNode.
* dom/ProcessingInstruction.h:
* dom/ShadowRoot.cpp:
(WebCore::ShadowRoot::cloneNodeInternal): Renamed from cloneNode. Also moved from ShadowRoot.h.
* dom/ShadowRoot.h:
* dom/Text.cpp:
(WebCore::Text::cloneNodeInternal): Renamed from cloneNode.
* dom/Text.h:
* html/HTMLTemplateElement.cpp:
(WebCore::HTMLTemplateElement::cloneNodeInternal): Renamed from cloneNode. This is the only
function in which CloneContent results in a different behavior from CloneSelf.
* html/HTMLTemplateElement.h:

LayoutTests:

Added a regression test.

* fast/dom/HTMLTemplateElement/cloneNode-nested-templates-expected.txt: Added.
* fast/dom/HTMLTemplateElement/cloneNode-nested-templates.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@177314 268f45cc-cd09-0410-ab3c-d52691b4dbfc
30 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/dom/HTMLTemplateElement/cloneNode-nested-templates-expected.txt [new file with mode: 0644]
LayoutTests/fast/dom/HTMLTemplateElement/cloneNode-nested-templates.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/dom/Attr.cpp
Source/WebCore/dom/Attr.h
Source/WebCore/dom/CDATASection.cpp
Source/WebCore/dom/CDATASection.h
Source/WebCore/dom/Comment.cpp
Source/WebCore/dom/Comment.h
Source/WebCore/dom/ContainerNode.cpp
Source/WebCore/dom/Document.cpp
Source/WebCore/dom/Document.h
Source/WebCore/dom/DocumentFragment.cpp
Source/WebCore/dom/DocumentFragment.h
Source/WebCore/dom/DocumentType.cpp
Source/WebCore/dom/DocumentType.h
Source/WebCore/dom/Element.cpp
Source/WebCore/dom/Element.h
Source/WebCore/dom/EntityReference.cpp
Source/WebCore/dom/EntityReference.h
Source/WebCore/dom/Node.h
Source/WebCore/dom/ProcessingInstruction.cpp
Source/WebCore/dom/ProcessingInstruction.h
Source/WebCore/dom/ShadowRoot.cpp
Source/WebCore/dom/ShadowRoot.h
Source/WebCore/dom/Text.cpp
Source/WebCore/dom/Text.h
Source/WebCore/html/HTMLTemplateElement.cpp
Source/WebCore/html/HTMLTemplateElement.h