Text
node nod
node . cloneNode([deep = false])
+ node . cloneNode([subtree = false])
node . {{Node/isEqualNode(otherNode)}}
@@ -4534,31 +4534,59 @@ each descendant exclusive Text
node nod
Specifications may define
cloning steps for all or some nodes. The
-algorithm is passed copy, node, document, and an optional
-clone children flag, as indicated in the clone algorithm.
+algorithm is passed node, copy, and subtree as indicated in the
+clone a single node algorithm.
-HTML defines cloning steps for <{script}> and <{input}> -elements. SVG ought to do the same for its <{script}> elements, but does not call this out -at the moment. +
HTML defines cloning steps for several elements, such as <{input}>, <{script}>, +and <{template}>. SVG ought to do the same for its <{script}> elements, but does not. -
To clone a -node, with an optional document and clone children flag, run these -steps: - +
To clone a node given a +node node and an optional document document (default +node's node document) and boolean subtree (default false):
If document is not given, then set document to node's - node document. -
Let copy be the result of cloning a single node given node, + document, and subtree. + +
If subtree is true, then clone a node's children given node, + copy, document, and subtree. + +
Return copy. +
To clone a node's children given a node node, a +node copy, a document document, and a boolean +subtree: + +
For each child of node's children, in tree order: + +
Let childCopy be the result of cloning a single node given + node, document, and subtree. + +
Append childCopy to copy. + +
Clone a node's children given child, childCopy, + document, and subtree. +
To clone a single node given a node node, +document document, and boolean subtree: + +
Let copy be null. +
If node is an element:
Let copy be the result of creating an element, given +
Set copy to the result of creating an element, given
document, node's local name, node's
namespace, node's namespace prefix, and
node's is
value.
@@ -4573,11 +4601,31 @@ dom-Range-extractContents, dom-Range-cloneContents -->
Append copyAttribute to copy.
If node is a shadow host and its + shadow root's clonable is true: + +
Assert: copy is not a shadow host. + +
Run attach a shadow root with copy, node's + shadow root's mode, true, node's + shadow root's serializable, node's + shadow root's delegates focus, and node's + shadow root's slot assignment. + +
Set copy's shadow root's declarative + to node's shadow root's declarative. + +
Clone a node's children given node's shadow root, + copy's shadow root, and document. +
Otherwise, let copy be a node that implements the same +
Otherwise, set copy to a node that implements the same interfaces as node, and fulfills these additional requirements, switching on the interface node implements: @@ -4607,53 +4655,28 @@ dom-Range-extractContents, dom-Range-cloneContents -->
Do nothing.
If node is a document, then set document to copy.
Set copy's node document to document.
Run any cloning steps defined for node in - other applicable specifications and pass copy, node, - document, and the clone children flag if set, as parameters. - -
If the clone children flag is set, then for each child - child of node, in tree order: append the result of - cloning child with document and the - clone children flag set, to copy. - -
If node is a shadow host whose shadow root's - clonable is true: - -
Assert: copy is not a shadow host. - -
Run attach a shadow root with copy, node's - shadow root's mode, true, node's - shadow root's serializable, node's - shadow root's delegates focus, and node's - shadow root's slot assignment. - -
Set copy's shadow root's declarative - to node's shadow root's declarative. - -
For each child child of node's - shadow root, in tree order: append the result of - cloning child with document and the - clone children flag set, to copy's shadow root. -
Return copy. -
The cloneNode(deep)
method steps are:
+
The cloneNode(subtree)
method steps are:
If this is a shadow root, then throw a "{{NotSupportedError!!exception}}" {{DOMException}}. -
Return a clone of this, with the - clone children flag set if deep is true. +
Return the result of cloning a node given this, this's + node document, and subtree.
A node A equals a @@ -5126,7 +5149,7 @@ interface Document : Node { [NewObject] Comment createComment(DOMString data); [NewObject] ProcessingInstruction createProcessingInstruction(DOMString target, DOMString data); - [CEReactions, NewObject] Node importNode(Node node, optional boolean deep = false); + [CEReactions, NewObject] Node importNode(Node node, optional boolean subtree = false); [CEReactions] Node adoptNode(Node node); [NewObject] Attr createAttribute(DOMString localName); @@ -5552,9 +5575,9 @@ method steps are:
Returns a copy of node. If deep is true, the copy also includes the +
Returns a copy of node. If subtree is true, the copy also includes the node's descendants.
If node is a document or a shadow root, throws a @@ -5571,15 +5594,15 @@ method steps are: "{{HierarchyRequestError!!exception}}" {{DOMException}}.
The importNode(node, deep)
+
The importNode(node, subtree)
method steps are:
If node is a document or shadow root, then throw a "{{NotSupportedError!!exception}}" {{DOMException}}. -
Return a clone of node, with this and the - clone children flag set if deep is true. +
Return the result of cloning a node given node, this, and + subtree.
Specifications may define