Skip to content

Commit b6019ad

Browse files
annevkdizhang168
authored andcommitted
Editorial: modernize the slot algorithms
Also stop exporting "find a slot" as it's not used elsewhere and address a couple markup errors identified by Bikeshed. Fixes #1349.
1 parent 0b1ca07 commit b6019ad

File tree

1 file changed

+49
-44
lines changed

1 file changed

+49
-44
lines changed

dom.bs

Lines changed: 49 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1731,7 +1731,7 @@ can only be used to influence an ongoing one.
17311731

17321732

17331733

1734-
<h2 id=aborting-ongoing-activities>Aborting ongoing activities</h3>
1734+
<h2 id=aborting-ongoing-activities>Aborting ongoing activities</h2>
17351735

17361736
<p>Though promises do not have a built-in aborting mechanism, many APIs using them require abort
17371737
semantics. {{AbortController}} is meant to support these requirements by providing an
@@ -2463,20 +2463,20 @@ reference to the <a>slot</a>, because this variable is not directly accessible f
24632463

24642464
<h5 id=finding-slots-and-slotables>Finding slots and slottables</h5>
24652465

2466-
<p>To <dfn export lt="find a slot|finding a slot">find a slot</dfn> for a given <a>slottable</a>
2467-
<var>slottable</var> and an optional <i>open flag</i> (unset unless stated otherwise), run these
2468-
steps:</p>
2466+
<div algorithm>
2467+
<p>To <dfn>find a slot</dfn> for a given <a for=/>slottable</a> <var>slottable</var> and an optional
2468+
boolean <var>open</var> (default false):
24692469

24702470
<ol>
2471-
<li><p>If <var>slottable</var>'s <a for=tree>parent</a> is null, then return null.</p></li>
2471+
<li><p>If <var>slottable</var>'s <a for=tree>parent</a> is null, then return null.
24722472

24732473
<li><p>Let <var>shadow</var> be <var>slottable</var>'s <a for=tree>parent</a>'s
2474-
<a for=Element>shadow root</a>.</p></li>
2474+
<a for=Element>shadow root</a>.
24752475

2476-
<li><p>If <var>shadow</var> is null, then return null.</p></li>
2476+
<li><p>If <var>shadow</var> is null, then return null.
24772477

2478-
<li><p>If the <i>open flag</i> is set and <var>shadow</var>'s <a for=ShadowRoot>mode</a> is
2479-
<em>not</em> "<code>open</code>", then return null.</p></li>
2478+
<li><p>If <var>open</var> is true and <var>shadow</var>'s <a for=ShadowRoot>mode</a> is not
2479+
"<code>open</code>", then return null.
24802480

24812481
<li><p>If <var>shadow</var>'s <a for=ShadowRoot>slot assignment</a> is "<code>manual</code>", then
24822482
return the <a>slot</a> in <var>shadow</var>'s <a for=tree>descendants</a> whose
@@ -2487,12 +2487,14 @@ steps:</p>
24872487
<a for=tree>descendants</a> whose <a for=slot>name</a> is <var>slottable</var>'s
24882488
<a for=slottable>name</a>, if any; otherwise null.
24892489
</ol>
2490+
</div>
24902491

2491-
<p>To <dfn export lt="find slottables|finding slottables" id=find-slotables>find slottables</dfn>
2492-
for a given <a>slot</a> <var>slot</var>, run these steps:</p>
2492+
<div algorithm>
2493+
<p>To <dfn export id=find-slotables>find slottables</dfn> for a given <a for=/>slot</a>
2494+
<var>slot</var>:
24932495

24942496
<ol>
2495-
<li><p>Let <var>result</var> be an empty list.</p></li>
2497+
<li><p>Let <var>result</var> be « ».
24962498

24972499
<li><p>Let <var>root</var> be <var>slot</var>'s <a for=tree>root</a>.
24982500

@@ -2504,8 +2506,6 @@ for a given <a>slot</a> <var>slot</var>, run these steps:</p>
25042506
<p>If <var>root</var>'s <a for=ShadowRoot>slot assignment</a> is "<code>manual</code>":
25052507

25062508
<ol>
2507-
<li><p>Let <var>result</var> be « ».
2508-
25092509
<li><p><a for=set>For each</a> <a>slottable</a> <var>slottable</var> of <var>slot</var>'s
25102510
<a>manually assigned nodes</a>, if <var>slottable</var>'s <a for=tree>parent</a> is
25112511
<var>host</var>, <a for=list>append</a> <var>slottable</var> to <var>result</var>.
@@ -2522,53 +2522,53 @@ for a given <a>slot</a> <var>slot</var>, run these steps:</p>
25222522
<li><p>If <var>foundSlot</var> is <var>slot</var>, then <a for=list>append</a>
25232523
<var>slottable</var> to <var>result</var>.
25242524
</ol>
2525-
</li>
25262525

2527-
<li><p>Return <var>result</var>.</p></li>
2526+
<li><p>Return <var>result</var>.
25282527
</ol>
2528+
</div>
25292529

2530-
<p>To
2531-
<dfn export lt="find flattened slottables|finding flattened slottables" id=find-flattened-slotables>find flattened slottables</dfn>
2532-
for a given <a>slot</a> <var>slot</var>, run these steps:</p>
2530+
<div algorithm>
2531+
<p>To <dfn export id=find-flattened-slotables>find flattened slottables</dfn> for a given
2532+
<a for=/>slot</a> <var>slot</var>:
25332533

25342534
<ol>
2535-
<li><p>Let <var>result</var> be an empty list.</p></li>
2535+
<li><p>Let <var>result</var> be « ».
25362536

25372537
<li><p>If <var>slot</var>'s <a for=tree>root</a> is not a <a for=/>shadow root</a>, then return
2538-
<var>result</var>.</p></li>
2538+
<var>result</var>.
25392539

25402540
<li><p>Let <var>slottables</var> be the result of <a>finding slottables</a> given
2541-
<var>slot</var>.</p></li>
2541+
<var>slot</var>.
25422542

25432543
<li><p>If <var>slottables</var> is the empty list, then append each <a>slottable</a>
2544-
<a for=tree>child</a> of <var>slot</var>, in <a>tree order</a>, to <var>slottables</var>.</p></li>
2544+
<a for=tree>child</a> of <var>slot</var>, in <a>tree order</a>, to <var>slottables</var>.
25452545

25462546
<li>
2547-
<p>For each <var>node</var> in <var>slottables</var>:
2547+
<p>For each <var>node</var> of <var>slottables</var>:
25482548

25492549
<ol>
25502550
<li>
25512551
<p>If <var>node</var> is a <a>slot</a> whose <a for=tree>root</a> is a <a for=/>shadow root</a>:
25522552

25532553
<ol>
25542554
<li><p>Let <var>temporaryResult</var> be the result of <a>finding flattened slottables</a> given
2555-
<var>node</var>.</p></li>
2555+
<var>node</var>.
25562556

25572557
<li><p>Append each <a>slottable</a> in <var>temporaryResult</var>, in order, to
2558-
<var>result</var>.</p></li>
2558+
<var>result</var>.
25592559
</ol>
25602560

2561-
<li><p>Otherwise, append <var>node</var> to <var>result</var>.</p></li>
2561+
<li><p>Otherwise, append <var>node</var> to <var>result</var>.
25622562
</ol>
2563-
</li>
25642563

2565-
<li><p>Return <var>result</var>.</p></li>
2564+
<li><p>Return <var>result</var>.
25662565
</ol>
2566+
</div>
25672567

25682568
<h5 id=assigning-slotables-and-slots>Assigning slottables and slots</h5>
25692569

2570-
<p>To <dfn noexport id=assign-slotables>assign slottables</dfn> for a <a>slot</a> <var>slot</var>,
2571-
run these steps:
2570+
<div algorithm>
2571+
<p>To <dfn id=assign-slotables>assign slottables</dfn> for a <a for=/>slot</a> <var>slot</var>:
25722572

25732573
<ol>
25742574
<li><p>Let <var>slottables</var> be the result of <a>finding slottables</a> for <var>slot</var>.
@@ -2578,36 +2578,42 @@ run these steps:
25782578

25792579
<li><p>Set <var>slot</var>'s <a for=slot>assigned nodes</a> to <var>slottables</var>.
25802580

2581-
<li><p>For each <var>slottable</var> in <var>slottables</var>, set <var>slottable</var>'s
2581+
<li><p>For each <var>slottable</var> of <var>slottables</var>, set <var>slottable</var>'s
25822582
<a>assigned slot</a> to <var>slot</var>.
25832583
</ol>
2584+
</div>
25842585

2585-
<p>To <dfn noexport id=assign-slotables-for-a-tree>assign slottables for a tree</dfn>, given a
2586-
<a for=/>node</a> <var>root</var>, run <a>assign slottables</a> for each <a>slot</a> <var>slot</var>
2587-
in <var>root</var>'s <a for=tree>inclusive descendants</a>, in <a>tree order</a>.
2586+
<div algorithm>
2587+
<p>To <dfn id=assign-slotables-for-a-tree>assign slottables for a tree</dfn>, given a
2588+
<a for=/>node</a> <var>root</var>, run <a>assign slottables</a> for each <a for=/>slot</a> of
2589+
<var>root</var>'s <a for=tree>inclusive descendants</a>, in <a>tree order</a>.
2590+
</div>
25882591

2589-
<p>To <dfn noexport>assign a slot</dfn>, given a <a>slottable</a> <var>slottable</var>, run these
2590-
steps:
2592+
<div algorithm>
2593+
<p>To <dfn>assign a slot</dfn>, given a <a>slottable</a> <var>slottable</var>:
25912594

25922595
<ol>
25932596
<li><p>Let <var>slot</var> be the result of <a>finding a slot</a> with <var>slottable</var>.
25942597

25952598
<li><p>If <var>slot</var> is non-null, then run <a>assign slottables</a> for <var>slot</var>.
25962599
</ol>
2600+
</div>
25972601

25982602
<h5 id=signaling-slot-change>Signaling slot change</h5>
25992603

26002604
<p>Each <a>similar-origin window agent</a> has <dfn noexport id=signal-slot-list>signal slots</dfn>
26012605
(a <a for=/>set</a> of <a>slots</a>), which is initially empty. [[!HTML]]
26022606

2603-
<p>To <dfn noexport>signal a slot change</dfn>, for a <a>slot</a> <var>slot</var>, run these steps:
2607+
<div algorithm>
2608+
<p>To <dfn>signal a slot change</dfn>, for a <a>slot</a> <var>slot</var>:
26042609

26052610
<ol>
26062611
<li><p><a for=set>Append</a> <var>slot</var> to <var>slot</var>'s <a>relevant agent</a>'s
26072612
<a>signal slots</a>.
26082613

26092614
<li><p><a>Queue a mutation observer microtask</a>.
26102615
</ol>
2616+
</div>
26112617

26122618

26132619
<h4 id=mutation-algorithms>Mutation algorithms</h4>
@@ -3456,8 +3462,7 @@ Text includes Slottable;
34563462
</pre>
34573463

34583464
<p>The <dfn attribute for=Slottable id=dom-slotable-assignedslot><code>assignedSlot</code></dfn>
3459-
getter steps are to return the result of <a>find a slot</a> given <a>this</a> and with the
3460-
<i>open flag</i> set.
3465+
getter steps are to return the result of <a>find a slot</a> given <a>this</a> and true.
34613466

34623467

34633468
<h4 id=old-style-collections>Old-style collections: {{NodeList}} and {{HTMLCollection}}</h4>
@@ -5301,7 +5306,7 @@ otherwise "<code>CSS1Compat</code>".
53015306
<dt><var>document</var> . {{Document/documentElement}}
53025307
<dd>Returns the <a>document element</a>.
53035308

5304-
<dt><var>collection</var> = <var>document</var> . {{Document/getElementsByTagName(qualifiedName)}}</code>
5309+
<dt><code><var>collection</var> = <var>document</var> . <a method for=Document lt="getElementsByTagName(qualifiedName)">getElementsByTagName</a>(<var>qualifiedName</var>)</code>
53055310

53065311
<dd>
53075312
<p>If <var>qualifiedName</var> is "<code>*</code>" returns an {{HTMLCollection}} of all
@@ -5312,7 +5317,7 @@ otherwise "<code>CSS1Compat</code>".
53125317
(Matches case-insensitively against <a for=/>elements</a> in the <a>HTML namespace</a> within an
53135318
<a>HTML document</a>.)
53145319

5315-
<dt><var>collection</var> = <var>document</var> . {{Document/getElementsByTagNameNS(namespace, localName)}}</code>
5320+
<dt><code><var>collection</var> = <var>document</var> . <a method for=Document lt="getElementsByTagNameNS(namespace, localName)">getElementsByTagNameNS</a>(<var>namespace</var>, <var>localName</var>)</code>
53165321

53175322
<dd>
53185323
<p>If <var>namespace</var> and <var>localName</var> are "<code>*</code>", returns an
@@ -5330,8 +5335,8 @@ otherwise "<code>CSS1Compat</code>".
53305335
<a for=/>elements</a> whose <a for=Element>namespace</a> is <var>namespace</var> and
53315336
<a for=Element>local name</a> is <var>localName</var>.
53325337

5333-
<dt><var>collection</var> = <var>document</var> . {{Document/getElementsByClassName(classNames)}}</code>
5334-
<dt><var>collection</var> = <var>element</var> . {{Element/getElementsByClassName(classNames)}}</code>
5338+
<dt><code><var>collection</var> = <var>document</var> . <a method for=Document lt="getElementsByClassName(classNames)">getElementsByClassName</a>(<var>classNames</var>)</code>
5339+
<dt><code><var>collection</var> = <var>element</var> . <a method for=Element lt="getElementsByClassName(classNames)">getElementsByClassName</a>(<var>classNames</var>)</code>
53355340
<dd><p>Returns an {{HTMLCollection}} of the <a for=/>elements</a> in the object on which the method
53365341
was invoked (a <a for=/>document</a> or an <a for=/>element</a>) that have all the classes given by
53375342
<var>classNames</var>. The <var>classNames</var> argument is interpreted as a space-separated list

0 commit comments

Comments
 (0)