@@ -4097,7 +4097,7 @@ interface Node : EventTarget {
4097
4097
[CEReactions] attribute DOMString? textContent;
4098
4098
[CEReactions] undefined normalize();
4099
4099
4100
- [CEReactions, NewObject] Node cloneNode(optional boolean deep = false);
4100
+ [CEReactions, NewObject] Node cloneNode(optional boolean subtree = false);
4101
4101
boolean isEqualNode(Node? otherNode);
4102
4102
boolean isSameNode(Node? otherNode); // legacy alias of ===
4103
4103
@@ -4521,9 +4521,9 @@ each <a for=tree>descendant</a> <a>exclusive <code>Text</code> node</a> <var>nod
4521
4521
<hr>
4522
4522
4523
4523
<dl class=domintro>
4524
- < dt > < code > < var > node</ var > . < a method for =Node lt =cloneNode() > cloneNode([< var > deep </ var > = false])</ a > </ code >
4524
+ <dt><code><var> node</var> . <a method for=Node lt=cloneNode()>cloneNode([<var>subtree </var> = false])</a> </code>
4525
4525
<dd> Returns a copy of <var> node</var> . If
4526
- < var > deep </ var > is true, the copy also includes the
4526
+ <var> subtree </var> is true, the copy also includes the
4527
4527
<var> node</var> 's <a for=tree>descendants</a> .
4528
4528
4529
4529
<dt><code><var> node</var> . {{Node/isEqualNode(otherNode)}} </code>
@@ -4533,33 +4533,82 @@ each <a for=tree>descendant</a> <a>exclusive <code>Text</code> node</a> <var>nod
4533
4533
4534
4534
<div class=impl>
4535
4535
4536
+ <div algorithm>
4536
4537
<a lt="Other applicable specifications">Specifications</a> may define
4537
4538
<dfn export id=concept-node-clone-ext>cloning steps</dfn> for all or some <a for=/>nodes</a> . The
4538
- algorithm is passed < var > copy </ var > , < var > node </ var > , < var > document </ var > , and an optional
4539
- < i > clone children flag </ i > , as indicated in the < a lt =" clone a node " > clone </ a > algorithm.
4539
+ algorithm is passed <var ignore> node </var> , <var ignore> copy </var> , and <var ignore> subtree </var> as
4540
+ indicated in the <a> clone a node</a> algorithm.
4540
4541
4541
- < p class =note > HTML defines < a > cloning steps</ a > for < {script} > and < {input} >
4542
- elements . SVG ought to do the same for its < {script}> elements, but does not call this out
4543
- at the moment.
4542
+ <p class=note> HTML defines <a>cloning steps</a> for several elements, such as <{input}> , <{script}> ,
4543
+ and <{template}> . SVG ought to do the same for its <{script}> elements, but does not.
4544
+ </div>
4544
4545
4545
- < p > To < dfn export id =concept-node-clone lt ="clone a node " local-lt ="clone "> clone</ dfn > a
4546
- < var > node</ var > , with an optional < var > document</ var > and < i > clone children flag</ i > , run these
4547
- steps:
4548
- <!-- This algorithm is used by dom-Node-cloneNode, dom-Document-importNode,
4549
- dom-Range-extractContents, dom-Range-cloneContents -->
4546
+ <div algorithm="clone a node">
4547
+ <p> To <dfn export id=concept-node-clone>clone a node</dfn> given a <a for=/>node</a> <var> node</var>
4548
+ and an optional <a for=/>document</a> <dfn export for="clone a node"><var>document</var></dfn>
4549
+ (default <var> node</var> 's <a for=Node>node document</a> ), boolean
4550
+ <dfn export for="clone a node"><var>subtree</var></dfn> (default false), and
4551
+ <a for=/>node</a> -or-null <dfn export for="clone a node"><var>parent</var></dfn> (default null):
4550
4552
4551
4553
<ol>
4552
- < li > < p > If < var > document </ var > is not given, then set < var > document</ var > to < var > node</ var > 's
4553
- < a for = Node > node document</ a > .
4554
+ <li><p> <a for=/>Assert</a> : < var>node </var> is not a <a for=/ >document</a> or <var> node</var> is
4555
+ <var> document</var > .
4554
4556
4555
- < li > < a for = / > Assert </ a > : < var > node </ var > is not a < a for = / > document </ a > or < var > node</ var > is
4557
+ <li><p> Let <var> copy </var> be the result of <a>cloning a single node </a> given <var> node</var> and
4556
4558
<var> document</var> .
4557
4559
4560
+ <li><p> If <var> parent</var> is non-null, then <a for=/>append</a> <var> copy</var> to
4561
+ <var> parent</var> .
4562
+
4563
+ <li><p> Run any <a>cloning steps</a> defined for <var> node</var> in
4564
+ <a>other applicable specifications</a> and pass <var> node</var> , <var> copy</var> , and
4565
+ <var> subtree</var> as parameters.
4566
+
4567
+ <li><p> If <var> subtree</var> is true, then for each <var> child</var> of <var> node</var> 's
4568
+ <a for=tree>children</a> , in <a>tree order</a> : <a>clone a node</a> given <var> child</var> with
4569
+ <a for="clone a node"><i>document</i></a> set to <var> document</var> ,
4570
+ <a for="clone a node"><i>subtree</i></a> set to <var> subtree</var> , and
4571
+ <a for="clone a node"><i>parent</i></a> set to <var> copy</var> .
4572
+
4573
+ <li>
4574
+ <p> If <var> node</var> is an <a for=/>element</a> , <a for=Element>shadow host</a> , and its
4575
+ <a for=Element>shadow root</a> 's <a for=ShadowRoot>clonable</a> is true:
4576
+
4577
+ <ol>
4578
+ <li><p> <a for=/>Assert</a> : <var> copy</var> is not a <a for=Element>shadow host</a> .
4579
+
4580
+ <li><p> <a>Attach a shadow root</a> with <var> copy</var> , <var> node</var> 's
4581
+ <a for=Element>shadow root</a> 's <a for=ShadowRoot>mode</a>, true, <var>node</var>' s
4582
+ <a for=Element>shadow root</a> 's <a for=ShadowRoot>serializable</a>, <var>node</var>' s
4583
+ <a for=Element>shadow root</a> 's <a for=ShadowRoot>delegates focus</a>, and <var>node</var>' s
4584
+ <a for=Element>shadow root</a> 's <a for=ShadowRoot>slot assignment</a> .
4585
+
4586
+ <li><p> Set <var> copy</var> 's <a for=Element>shadow root</a>' s <a for=ShadowRoot>declarative</a>
4587
+ to <var> node</var> 's <a for=Element>shadow root</a>' s <a for=ShadowRoot>declarative</a> .
4588
+
4589
+ <li><p> For each <var> child</var> of <var> node</var> 's <a for=Element>shadow root</a>' s
4590
+ <a for=tree>children</a> , in <a>tree order</a> : <a>clone a node</a> given <var> child</var> with
4591
+ <a for="clone a node"><i>document</i></a> set to <var> document</var> ,
4592
+ <a for="clone a node"><i>subtree</i></a> set to <var> subtree</var> , and
4593
+ <a for="clone a node"><i>parent</i></a> set to <var> copy</var> 's <a for=Element>shadow root</a> .
4594
+ </ol>
4595
+
4596
+ <li><p> Return <var> copy</var> .
4597
+ </ol>
4598
+ </div>
4599
+
4600
+ <div algorithm>
4601
+ <p> To <dfn>clone a single node</dfn> given a <a for=/>node</a> <var> node</var> and
4602
+ <a for=/>document</a> <var> document</var> :
4603
+
4604
+ <ol>
4605
+ <li><p> Let <var> copy</var> be null.
4606
+
4558
4607
<li>
4559
4608
<p> If <var> node</var> is an <a for=/>element</a> :
4560
4609
4561
4610
<ol>
4562
- < li > < p > Let < var > copy</ var > be the result of < a > creating an element</ a > , given
4611
+ <li><p> Set <var> copy</var> to the result of <a>creating an element</a> , given
4563
4612
<var> document</var> , <var> node</var> 's <a for=Element>local name</a>, <var>node</var>' s
4564
4613
<a for=Element>namespace</a> , <var> node</var> 's <a for=Element>namespace prefix</a> , and
4565
4614
<var> node</var> 's <a><code>is</code> value</a> .
@@ -4569,16 +4618,15 @@ dom-Range-extractContents, dom-Range-cloneContents -->
4569
4618
<a for=Element>attribute list</a> :
4570
4619
4571
4620
<ol>
4572
- < li > < p > Let < var > copyAttribute</ var > be a < a > clone</ a > of < var > attribute</ var > .
4621
+ <li><p> Let <var> copyAttribute</var> be the result of <a>cloning a single node</a> given
4622
+ <var> attribute</var> and <var> document</var> .
4573
4623
4574
4624
<li><p> <a lt="append an attribute">Append</a> <var> copyAttribute</var> to <var> copy</var> .
4575
4625
</ol>
4576
- </ li >
4577
4626
</ol>
4578
- </ li >
4579
4627
4580
4628
<li>
4581
- < p > Otherwise, let < var > copy</ var > be a < a for =/ > node</ a > that < a > implements</ a > the same
4629
+ <p> Otherwise, set <var> copy</var> to a <a for=/>node</a> that <a>implements</a> the same
4582
4630
interfaces as <var> node</var> , and fulfills these additional requirements, switching on the
4583
4631
interface <var> node</var> <a>implements</a> :
4584
4632
@@ -4608,54 +4656,28 @@ dom-Range-extractContents, dom-Range-cloneContents -->
4608
4656
<dd><p> Do nothing.
4609
4657
</dl>
4610
4658
4659
+ <li><p> <a for=/>Assert</a> : <var> copy</var> is a <a for=/>node</a> .
4660
+
4611
4661
<li><p> If <var> node</var> is a <a for=/>document</a> , then set <var> document</var> to
4612
4662
<var> copy</var> .
4613
4663
4614
4664
<li><p> Set <var> copy</var> 's <a for=Node>node document</a> to <var> document</var> .
4615
4665
4616
- < li > < p > Run any < a > cloning steps</ a > defined for < var > node</ var > in
4617
- < a > other applicable specifications</ a > and pass < var > copy</ var > , < var > node</ var > ,
4618
- < var > document</ var > , and the < i > clone children flag</ i > if set, as parameters.
4619
-
4620
- < li > < p > If the < i > clone children flag</ i > is set, then for each < a for =tree > child</ a >
4621
- < var > child</ var > of < var > node</ var > , in < a > tree order</ a > : < a > append</ a > the result of
4622
- < a lt ="clone a node "> cloning</ a > < var > child</ var > with < var > document</ var > and the
4623
- < i > clone children flag</ i > set, to < var > copy</ var > .
4624
-
4625
- < li >
4626
- < p > If < var > node</ var > is a < a for =Element > shadow host</ a > whose < a for =/ > shadow root</ a > 's
4627
- < a for =ShadowRoot > clonable</ a > is true:
4628
-
4629
- < ol >
4630
- < li > < p > Assert: < var > copy</ var > is not a < a for =Element > shadow host</ a > .
4631
-
4632
- < li > < p > Run < a > attach a shadow root</ a > with < var > copy</ var > , < var > node</ var > 's
4633
- < a for =Element > shadow root</ a > 's < a for =ShadowRoot > mode</ a > , true, < var > node</ var > 's
4634
- < a for =Element > shadow root</ a > 's < a for =ShadowRoot > serializable</ a > , < var > node</ var > 's
4635
- < a for =Element > shadow root</ a > 's < a for =ShadowRoot > delegates focus</ a > , and < var > node</ var > 's
4636
- < a for =Element > shadow root</ a > 's < a for =ShadowRoot > slot assignment</ a > .
4637
-
4638
- < li > < p > Set < var > copy</ var > 's < a for =Element > shadow root</ a > 's < a for =ShadowRoot > declarative</ a >
4639
- to < var > node</ var > 's < a for =Element > shadow root</ a > 's < a for =ShadowRoot > declarative</ a > .
4640
-
4641
- < li > < p > For each < a for =tree > child</ a > < var > child</ var > of < var > node</ var > 's
4642
- < a for =Element > shadow root</ a > , in < a > tree order</ a > : < a > append</ a > the result of
4643
- < a lt ="clone a node "> cloning</ a > < var > child</ var > with < var > document</ var > and the
4644
- < i > clone children flag</ i > set, to < var > copy</ var > 's < a for =Element > shadow root</ a > .
4645
- </ ol >
4646
-
4647
4666
<li><p> Return <var> copy</var> .
4648
4667
</ol>
4668
+ </div>
4649
4669
4650
- < p > The < dfn method for =Node > < code > cloneNode(< var > deep</ var > )</ code > </ dfn > method steps are:
4670
+ <div algorithm>
4671
+ <p> The <dfn method for=Node><code>cloneNode(<var>subtree</var>)</code></dfn> method steps are:
4651
4672
4652
4673
<ol>
4653
4674
<li><p> If <a>this</a> is a <a for=/>shadow root</a> , then <a>throw</a> a
4654
4675
"{{NotSupportedError!!exception}} " {{DOMException}} .
4655
4676
4656
- < li > < p > Return a < a lt =" clone a node" > clone </ a > of < a > this</ a > , with the
4657
- < i > clone children flag < /i > set if < var > deep </ var > is true .
4677
+ <li><p> Return the result of <a>cloning a node</a> given <a>this</a> with
4678
+ <a for=" clone a node"><i>subtree< /i></a> set to <var> subtree </var> .
4658
4679
</ol>
4680
+ </div>
4659
4681
4660
4682
<p> A <a for=/>node</a> <var> A</var> <dfn export for=Node id=concept-node-equals>equals</dfn> a
4661
4683
<a for=/>node</a> <var> B</var> if all of the following conditions are true:
@@ -5127,7 +5149,7 @@ interface Document : Node {
5127
5149
[NewObject] Comment createComment(DOMString data);
5128
5150
[NewObject] ProcessingInstruction createProcessingInstruction(DOMString target, DOMString data);
5129
5151
5130
- [CEReactions, NewObject] Node importNode(Node node, optional boolean deep = false);
5152
+ [CEReactions, NewObject] Node importNode(Node node, optional boolean subtree = false);
5131
5153
[CEReactions] Node adoptNode(Node node);
5132
5154
5133
5155
[NewObject] Attr createAttribute(DOMString localName);
@@ -5554,9 +5576,9 @@ method steps are:
5554
5576
<hr>
5555
5577
5556
5578
<dl class=domintro>
5557
- < dt > < var > clone</ var > = < var > document</ var > . < a method for =Document lt =importNode() > importNode(< var > node</ var > [, < var > deep </ var > = false])</ a >
5579
+ <dt><var> clone</var> = <var> document</var> . <a method for=Document lt=importNode()>importNode(<var>node</var> [, <var>subtree </var> = false])</a>
5558
5580
<dd>
5559
- < p > Returns a copy of < var > node</ var > . If < var > deep </ var > is true, the copy also includes the
5581
+ <p> Returns a copy of <var> node</var> . If <var> subtree </var> is true, the copy also includes the
5560
5582
<var> node</var> 's <a for=tree>descendants</a> .
5561
5583
5562
5584
<p> If <var> node</var> is a <a for=/>document</a> or a <a for=/>shadow root</a> , throws a
@@ -5573,16 +5595,19 @@ method steps are:
5573
5595
"{{HierarchyRequestError!!exception}} " {{DOMException}} .
5574
5596
</dl>
5575
5597
5576
- < p > The < dfn method for =Document > < code > importNode(< var > node</ var > , < var > deep</ var > )</ code > </ dfn >
5598
+ <div algorithm>
5599
+ <p> The <dfn method for=Document><code>importNode(<var>node</var>, <var>subtree</var>)</code></dfn>
5577
5600
method steps are:
5578
5601
5579
5602
<ol>
5580
5603
<li><p> If <var> node</var> is a <a for=/>document</a> or <a for=/>shadow root</a> , then <a>throw</a>
5581
5604
a "{{NotSupportedError!!exception}} " {{DOMException}} .
5582
5605
5583
- < li > < p > Return a < a lt ="clone a node "> clone</ a > of < var > node</ var > , with < a > this</ a > and the
5584
- < i > clone children flag</ i > set if < var > deep</ var > is true.
5606
+ <li><p> Return the result of <a>cloning a node</a> given <var> node</var> with
5607
+ <a for="clone a node"><i>document</i></a> set to <a>this</a> and
5608
+ <a for="clone a node"><i>subtree</i></a> set to <var> subtree</var> .
5585
5609
</ol>
5610
+ </div>
5586
5611
5587
5612
<p> <a lt="Other applicable specifications">Specifications</a> may define
5588
5613
<dfn export id=concept-node-adopt-ext>adopting steps</dfn> for all or some <a for=/>nodes</a> . The
0 commit comments