Skip to content

Commit e6bb175

Browse files
authored
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 369654b commit e6bb175

File tree

1 file changed

+49
-44
lines changed

1 file changed

+49
-44
lines changed

dom.bs

+49-44
Original file line numberDiff line numberDiff line change
@@ -1729,7 +1729,7 @@ can only be used to influence an ongoing one.
17291729

17301730

17311731

1732-
<h2 id=aborting-ongoing-activities>Aborting ongoing activities</h3>
1732+
<h2 id=aborting-ongoing-activities>Aborting ongoing activities</h2>
17331733

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

24622462
<h5 id=finding-slots-and-slotables>Finding slots and slottables</h5>
24632463

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

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

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

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

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

24792479
<li><p>If <var>shadow</var>'s <a for=ShadowRoot>slot assignment</a> is "<code>manual</code>", then
24802480
return the <a>slot</a> in <var>shadow</var>'s <a for=tree>descendants</a> whose
@@ -2485,12 +2485,14 @@ steps:</p>
24852485
<a for=tree>descendants</a> whose <a for=slot>name</a> is <var>slottable</var>'s
24862486
<a for=slottable>name</a>, if any; otherwise null.
24872487
</ol>
2488+
</div>
24882489

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

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

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

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

25042506
<ol>
2505-
<li><p>Let <var>result</var> be « ».
2506-
25072507
<li><p><a for=set>For each</a> <a>slottable</a> <var>slottable</var> of <var>slot</var>'s
25082508
<a>manually assigned nodes</a>, if <var>slottable</var>'s <a for=tree>parent</a> is
25092509
<var>host</var>, <a for=list>append</a> <var>slottable</var> to <var>result</var>.
@@ -2520,53 +2520,53 @@ for a given <a>slot</a> <var>slot</var>, run these steps:</p>
25202520
<li><p>If <var>foundSlot</var> is <var>slot</var>, then <a for=list>append</a>
25212521
<var>slottable</var> to <var>result</var>.
25222522
</ol>
2523-
</li>
25242523

2525-
<li><p>Return <var>result</var>.</p></li>
2524+
<li><p>Return <var>result</var>.
25262525
</ol>
2526+
</div>
25272527

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

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

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

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

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

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

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

25512551
<ol>
25522552
<li><p>Let <var>temporaryResult</var> be the result of <a>finding flattened slottables</a> given
2553-
<var>node</var>.</p></li>
2553+
<var>node</var>.
25542554

25552555
<li><p>Append each <a>slottable</a> in <var>temporaryResult</var>, in order, to
2556-
<var>result</var>.</p></li>
2556+
<var>result</var>.
25572557
</ol>
25582558

2559-
<li><p>Otherwise, append <var>node</var> to <var>result</var>.</p></li>
2559+
<li><p>Otherwise, append <var>node</var> to <var>result</var>.
25602560
</ol>
2561-
</li>
25622561

2563-
<li><p>Return <var>result</var>.</p></li>
2562+
<li><p>Return <var>result</var>.
25642563
</ol>
2564+
</div>
25652565

25662566
<h5 id=assigning-slotables-and-slots>Assigning slottables and slots</h5>
25672567

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

25712571
<ol>
25722572
<li><p>Let <var>slottables</var> be the result of <a>finding slottables</a> for <var>slot</var>.
@@ -2576,36 +2576,42 @@ run these steps:
25762576

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

2579-
<li><p>For each <var>slottable</var> in <var>slottables</var>, set <var>slottable</var>'s
2579+
<li><p>For each <var>slottable</var> of <var>slottables</var>, set <var>slottable</var>'s
25802580
<a>assigned slot</a> to <var>slot</var>.
25812581
</ol>
2582+
</div>
25822583

2583-
<p>To <dfn noexport id=assign-slotables-for-a-tree>assign slottables for a tree</dfn>, given a
2584-
<a for=/>node</a> <var>root</var>, run <a>assign slottables</a> for each <a>slot</a> <var>slot</var>
2585-
in <var>root</var>'s <a for=tree>inclusive descendants</a>, in <a>tree order</a>.
2584+
<div algorithm>
2585+
<p>To <dfn 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 for=/>slot</a> of
2587+
<var>root</var>'s <a for=tree>inclusive descendants</a>, in <a>tree order</a>.
2588+
</div>
25862589

2587-
<p>To <dfn noexport>assign a slot</dfn>, given a <a>slottable</a> <var>slottable</var>, run these
2588-
steps:
2590+
<div algorithm>
2591+
<p>To <dfn>assign a slot</dfn>, given a <a>slottable</a> <var>slottable</var>:
25892592

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

25932596
<li><p>If <var>slot</var> is non-null, then run <a>assign slottables</a> for <var>slot</var>.
25942597
</ol>
2598+
</div>
25952599

25962600
<h5 id=signaling-slot-change>Signaling slot change</h5>
25972601

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

2601-
<p>To <dfn noexport>signal a slot change</dfn>, for a <a>slot</a> <var>slot</var>, run these steps:
2605+
<div algorithm>
2606+
<p>To <dfn>signal a slot change</dfn>, for a <a>slot</a> <var>slot</var>:
26022607

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

26072612
<li><p><a>Queue a mutation observer microtask</a>.
26082613
</ol>
2614+
</div>
26092615

26102616

26112617
<h4 id=mutation-algorithms>Mutation algorithms</h4>
@@ -3446,8 +3452,7 @@ Text includes Slottable;
34463452
</pre>
34473453

34483454
<p>The <dfn attribute for=Slottable id=dom-slotable-assignedslot><code>assignedSlot</code></dfn>
3449-
getter steps are to return the result of <a>find a slot</a> given <a>this</a> and with the
3450-
<i>open flag</i> set.
3455+
getter steps are to return the result of <a>find a slot</a> given <a>this</a> and true.
34513456

34523457

34533458
<h4 id=old-style-collections>Old-style collections: {{NodeList}} and {{HTMLCollection}}</h4>
@@ -5291,7 +5296,7 @@ otherwise "<code>CSS1Compat</code>".
52915296
<dt><var>document</var> . {{Document/documentElement}}
52925297
<dd>Returns the <a>document element</a>.
52935298

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

52965301
<dd>
52975302
<p>If <var>qualifiedName</var> is "<code>*</code>" returns an {{HTMLCollection}} of all
@@ -5302,7 +5307,7 @@ otherwise "<code>CSS1Compat</code>".
53025307
(Matches case-insensitively against <a for=/>elements</a> in the <a>HTML namespace</a> within an
53035308
<a>HTML document</a>.)
53045309

5305-
<dt><var>collection</var> = <var>document</var> . {{Document/getElementsByTagNameNS(namespace, localName)}}</code>
5310+
<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>
53065311

53075312
<dd>
53085313
<p>If <var>namespace</var> and <var>localName</var> are "<code>*</code>", returns an
@@ -5320,8 +5325,8 @@ otherwise "<code>CSS1Compat</code>".
53205325
<a for=/>elements</a> whose <a for=Element>namespace</a> is <var>namespace</var> and
53215326
<a for=Element>local name</a> is <var>localName</var>.
53225327

5323-
<dt><var>collection</var> = <var>document</var> . {{Document/getElementsByClassName(classNames)}}</code>
5324-
<dt><var>collection</var> = <var>element</var> . {{Element/getElementsByClassName(classNames)}}</code>
5328+
<dt><code><var>collection</var> = <var>document</var> . <a method for=Document lt="getElementsByClassName(classNames)">getElementsByClassName</a>(<var>classNames</var>)</code>
5329+
<dt><code><var>collection</var> = <var>element</var> . <a method for=Element lt="getElementsByClassName(classNames)">getElementsByClassName</a>(<var>classNames</var>)</code>
53255330
<dd><p>Returns an {{HTMLCollection}} of the <a for=/>elements</a> in the object on which the method
53265331
was invoked (a <a for=/>document</a> or an <a for=/>element</a>) that have all the classes given by
53275332
<var>classNames</var>. The <var>classNames</var> argument is interpreted as a space-separated list

0 commit comments

Comments
 (0)