diff --git a/dom.bs b/dom.bs index 0b7a6bd2..601a05f1 100644 --- a/dom.bs +++ b/dom.bs @@ -4097,7 +4097,7 @@ interface Node : EventTarget { [CEReactions] attribute DOMString? textContent; [CEReactions] undefined normalize(); - [CEReactions, NewObject] Node cloneNode(optional boolean deep = false); + [CEReactions, NewObject] Node cloneNode(optional boolean subtree = false); boolean isEqualNode(Node? otherNode); boolean isSameNode(Node? otherNode); // legacy alias of === @@ -4520,9 +4520,9 @@ each descendant exclusive Text node nod
-
node . cloneNode([deep = false]) +
node . cloneNode([subtree = false])
Returns a copy of node. If - deep is true, the copy also includes the + subtree is true, the copy also includes the node's descendants.
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):

    -
  1. If document is not given, then set document to node's - node document. -

  2. Assert: node is not a document or node is document. +
  3. Let copy be the result of cloning a single node given node, + document, and subtree. + +

  4. If subtree is true, then clone a node's children given node, + copy, document, and subtree. + +

  5. Return copy. +

+ +

To clone a node's children given a node node, a +node copy, a document document, and a boolean +subtree: + +

    +
  1. +

    For each child of node's children, in tree order: + +

      +
    1. Let childCopy be the result of cloning a single node given + node, document, and subtree. + +

    2. Append childCopy to copy. + +

    3. 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: + +

    +
  1. Let copy be null. +

  2. If node is an element:

      -
    1. Let copy be the result of creating an element, given +

    2. 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 -->

    3. Append copyAttribute to copy.

  3. + +
  4. +

    If node is a shadow host and its + shadow root's clonable is true: + +

      +
    1. Assert: copy is not a shadow host. + +

    2. 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. + +

    3. Set copy's shadow root's declarative + to node's shadow root's declarative. + +

    4. 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.

  • +
  • Assert: copy is a node. +

  • 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: - -

      -
    1. Assert: copy is not a shadow host. - -

    2. 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. - -

    3. Set copy's shadow root's declarative - to node's shadow root's declarative. - -

    4. 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. -

    + other applicable specifications and pass node, copy, and + subtree.
  • Return copy. -

    The cloneNode(deep) method steps are: +

    The cloneNode(subtree) method steps are:

    1. If this is a shadow root, then throw a "{{NotSupportedError!!exception}}" {{DOMException}}. -

    2. Return a clone of this, with the - clone children flag set if deep is true. +

    3. 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:


    -
    clone = document . importNode(node [, deep = false]) +
    clone = document . importNode(node [, subtree = false])
    -

    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:

    1. If node is a document or shadow root, then throw a "{{NotSupportedError!!exception}}" {{DOMException}}. -

    2. Return a clone of node, with this and the - clone children flag set if deep is true. +

    3. Return the result of cloning a node given node, this, and + subtree.

    Specifications may define