Skip to content

Commit 769aedf

Browse files
committed
Editorial: modernize convert nodes into a node
And adopt more <div algorithm> around there.
1 parent 61246e6 commit 769aedf

File tree

1 file changed

+50
-11
lines changed

1 file changed

+50
-11
lines changed

dom.bs

Lines changed: 50 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3377,10 +3377,12 @@ DocumentFragment includes NonElementParentNode;
33773377
whose <a for=Element>ID</a> is <var>elementId</var>.
33783378
</dl>
33793379

3380+
<div algorithm>
33803381
<p>The <dfn method for=NonElementParentNode><code>getElementById(<var>elementId</var>)</code></dfn>
33813382
method steps are to return the first <a for=/>element</a>, in <a>tree order</a>, within
33823383
<a>this</a>'s <a for=tree>descendants</a>, whose <a for=Element>ID</a> is <var>elementId</var>;
33833384
otherwise, if there is no such <a for=/>element</a>, null.
3385+
</div>
33843386

33853387

33863388
<h4 id=mixin-documentorshadowroot>Mixin {{DocumentOrShadowRoot}}</h4>
@@ -3399,6 +3401,7 @@ ShadowRoot includes DocumentOrShadowRoot;
33993401
otherwise null.
34003402
</dl>
34013403

3404+
<div algorithm>
34023405
<p>The <dfn attribute for=DocumentOrShadowRoot><code>customElementRegistry</code></dfn> getter steps
34033406
are:
34043407

@@ -3410,6 +3413,7 @@ are:
34103413

34113414
<li><p>Return <a>this</a>'s <a for=ShadowRoot>custom element registry</a>.
34123415
</ol>
3416+
</div>
34133417

34143418
<p class=note>The {{DocumentOrShadowRoot}} mixin is also expected to be used by other
34153419
standards that want to define APIs shared between <a for=/>documents</a> and
@@ -3418,25 +3422,26 @@ standards that want to define APIs shared between <a for=/>documents</a> and
34183422

34193423
<h4 id=interface-parentnode>Mixin {{ParentNode}}</h4>
34203424

3421-
<p>To <dfn export lt="converting nodes into a node">convert nodes into a node</dfn>, given
3422-
<var>nodes</var> and <var>document</var>, run these steps:
3425+
<div algorithm>
3426+
<p>To <dfn>convert nodes into a node</dfn>, given a <a for=/>list</a> of <a for=/>nodes</a> and
3427+
strings <var>nodes</var>, and <a for=/>document</a> <var>document</var>:
34233428

34243429
<ol>
3425-
<li><p>Let <var>node</var> be null.
3426-
3427-
<li><p>Replace each string in <var>nodes</var> with a new {{Text}} <a for=/>node</a> whose
3430+
<li><p>Replace each string of <var>nodes</var> with a new {{Text}} <a for=/>node</a> whose
34283431
<a for=CharacterData>data</a> is the string and <a for=Node>node document</a> is
34293432
<var>document</var>.
34303433

3431-
<li><p>If <var>nodes</var> contains one <a for=/>node</a>, then set <var>node</var> to
3432-
<var>nodes</var>[0].
3434+
<li><p>If <var>nodes</var>'s <a for=list>size</a> is 1, then return <var>nodes</var>[0].
34333435

3434-
<li><p>Otherwise, set <var>node</var> to a new {{DocumentFragment}} <a for=/>node</a> whose
3435-
<a for=Node>node document</a> is <var>document</var>, and then <a>append</a> each <a for=/>node</a>
3436-
in <var>nodes</var>, if any, to it.
3436+
<li><p>Let <var>fragment</var> be a new {{DocumentFragment}} <a for=/>node</a> whose
3437+
<a for=Node>node document</a> is <var>document</var>.
34373438

3438-
<li><p>Return <var>node</var>.
3439+
<li><p>For each <var>node</var> of <var>nodes</var>: <a>append</a> <var>node</var> to
3440+
<var>fragment</var>.
3441+
3442+
<li><p>Return <var>fragment</var>.
34393443
</ol>
3444+
</div>
34403445

34413446
<pre class=idl>
34423447
interface mixin ParentNode {
@@ -3518,19 +3523,28 @@ Element includes ParentNode;
35183523
<var>selectors</var>.
35193524
</dl>
35203525

3526+
<div algorithm>
35213527
<p>The <dfn attribute for=ParentNode><code>children</code></dfn> getter steps are to return an
35223528
{{HTMLCollection}} <a>collection</a> rooted at <a>this</a> matching only <a for=/>element</a>
35233529
<a for=tree>children</a>.
3530+
</div>
35243531

3532+
<div algorithm>
35253533
<p>The <dfn attribute for=ParentNode><code>firstElementChild</code></dfn> getter steps are to return
35263534
the first <a for=tree>child</a> that is an <a for=/>element</a>; otherwise null.
3535+
</div>
35273536

3537+
<div algorithm>
35283538
<p>The <dfn attribute for=ParentNode><code>lastElementChild</code></dfn> getter steps are to return
35293539
the last <a for=tree>child</a> that is an <a for=/>element</a>; otherwise null.
3540+
</div>
35303541

3542+
<div algorithm>
35313543
<p>The <dfn attribute for=ParentNode><code>childElementCount</code></dfn> getter steps are to return
35323544
the number of <a for=tree>children</a> of <a>this</a> that are <a for=/>elements</a>.
3545+
</div>
35333546

3547+
<div algorithm>
35343548
<p>The <dfn method for=ParentNode><code>prepend(<var>nodes</var>)</code></dfn> method steps are:
35353549

35363550
<ol>
@@ -3540,7 +3554,9 @@ the number of <a for=tree>children</a> of <a>this</a> that are <a for=/>elements
35403554
<li><p><a>Pre-insert</a> <var>node</var> into <a>this</a> before <a>this</a>'s
35413555
<a for=tree>first child</a>.
35423556
</ol>
3557+
</div>
35433558

3559+
<div algorithm>
35443560
<p>The <dfn method for=ParentNode><code>append(<var>nodes</var>)</code></dfn> method steps are:
35453561

35463562
<ol>
@@ -3549,7 +3565,9 @@ the number of <a for=tree>children</a> of <a>this</a> that are <a for=/>elements
35493565

35503566
<li><p><a>Append</a> <var>node</var> to <a>this</a>.
35513567
</ol>
3568+
</div>
35523569

3570+
<div algorithm>
35533571
<p>The <dfn method for=ParentNode><code>replaceChildren(<var>nodes</var>)</code></dfn> method steps
35543572
are:
35553573

@@ -3561,7 +3579,9 @@ are:
35613579

35623580
<li><p><a for=Node>Replace all</a> with <var>node</var> within <a>this</a>.
35633581
</ol>
3582+
</div>
35643583

3584+
<div algorithm>
35653585
<p>The <dfn method for=ParentNode><code>moveBefore(<var>node</var>, <var>child</var>)</code></dfn>
35663586
method steps are:
35673587

@@ -3573,14 +3593,19 @@ method steps are:
35733593

35743594
<li><p><a for=/>Move</a> <var>node</var> into <a>this</a> before <var>referenceChild</var>.
35753595
</ol>
3596+
</div>
35763597

3598+
<div algorithm>
35773599
<p>The <dfn method for=ParentNode><code>querySelector(<var>selectors</var>)</code></dfn> method
35783600
steps are to return the first result of running <a>scope-match a selectors string</a>
35793601
<var>selectors</var> against <a>this</a>, if the result is not an empty list; otherwise null.
3602+
</div>
35803603

3604+
<div algorithm>
35813605
<p>The <dfn method for=ParentNode><code>querySelectorAll(<var>selectors</var>)</code></dfn> method
35823606
steps are to return the <a lt="static collection">static</a> result of running
35833607
<a>scope-match a selectors string</a> <var>selectors</var> against <a>this</a>.
3608+
</div>
35843609

35853610

35863611
<h4 id=interface-nondocumenttypechildnode>Mixin {{NonDocumentTypeChildNode}}</h4>
@@ -3608,13 +3633,17 @@ CharacterData includes NonDocumentTypeChildNode;
36083633
otherwise null.
36093634
</dl>
36103635

3636+
<div algorithm>
36113637
<p>The <dfn attribute for=NonDocumentTypeChildNode><code>previousElementSibling</code></dfn> getter
36123638
steps are to return the first <a>preceding</a> <a for=tree>sibling</a> that is an
36133639
<a for=/>element</a>; otherwise null.
3640+
</div>
36143641

3642+
<div algorithm>
36153643
<p>The <dfn attribute for=NonDocumentTypeChildNode><code>nextElementSibling</code></dfn> getter
36163644
steps are to return the first <a>following</a> <a for=tree>sibling</a> that is an
36173645
<a for=/>element</a>; otherwise null.
3646+
</div>
36183647

36193648

36203649
<h4 id=interface-childnode>Mixin {{ChildNode}}</h4>
@@ -3660,6 +3689,7 @@ CharacterData includes ChildNode;
36603689
<dd>Removes <var>node</var>.
36613690
</dl>
36623691

3692+
<div algorithm>
36633693
<p>The <dfn method for=ChildNode><code>before(<var>nodes</var>)</code></dfn> method steps are:
36643694

36653695
<ol>
@@ -3680,7 +3710,9 @@ CharacterData includes ChildNode;
36803710
<li><p><a>Pre-insert</a> <var>node</var> into <var>parent</var> before
36813711
<var>viablePreviousSibling</var>.
36823712
</ol>
3713+
</div>
36833714

3715+
<div algorithm>
36843716
<p>The <dfn method for=ChildNode><code>after(<var>nodes</var>)</code></dfn> method steps are:
36853717

36863718
<ol>
@@ -3697,7 +3729,9 @@ CharacterData includes ChildNode;
36973729
<li><p><a>Pre-insert</a> <var>node</var> into <var>parent</var> before
36983730
<var>viableNextSibling</var>.
36993731
</ol>
3732+
</div>
37003733

3734+
<div algorithm>
37013735
<p>The <dfn method for=ChildNode><code>replaceWith(<var>nodes</var>)</code></dfn> method steps are:
37023736

37033737
<ol>
@@ -3720,14 +3754,17 @@ CharacterData includes ChildNode;
37203754
<li><p>Otherwise, <a>pre-insert</a> <var>node</var> into <var>parent</var> before
37213755
<var>viableNextSibling</var>.
37223756
</ol>
3757+
</div>
37233758

3759+
<div algorithm>
37243760
<p>The <dfn method for=ChildNode><code>remove()</code></dfn> method steps are:
37253761

37263762
<ol>
37273763
<li><p>If <a>this</a>'s <a for=tree>parent</a> is null, then return.
37283764

37293765
<li><p><a for=/>Remove</a> <a>this</a>.
37303766
</ol>
3767+
</div>
37313768

37323769

37333770
<h4 id=mixin-slotable>Mixin {{Slottable}}</h4>
@@ -3740,8 +3777,10 @@ Element includes Slottable;
37403777
Text includes Slottable;
37413778
</pre>
37423779

3780+
<div algorithm>
37433781
<p>The <dfn attribute for=Slottable id=dom-slotable-assignedslot><code>assignedSlot</code></dfn>
37443782
getter steps are to return the result of <a>find a slot</a> given <a>this</a> and true.
3783+
</div>
37453784

37463785

37473786
<h4 id=old-style-collections>Old-style collections: {{NodeList}} and {{HTMLCollection}}</h4>

0 commit comments

Comments
 (0)