Skip to content

Commit

Permalink
Fix errors related to <slot> elements in auto directionality traversal
Browse files Browse the repository at this point in the history
This fixes some related errors in the section on auto directionality
traversal that I made recently in
1dc4c7557f5a4c879c1ce65b9cb59b91310bbf5 (PR #9796, fixing #3699).

This list item specifies an algorithm that implementors are expected to
turn into a traversal of a subtree that skips parts of the subtree.
However, by describing the skipping test in the first sub-item as
examining ancestors rather than ancestors-or-self, it introduces a
subtle difference between the algorithm that an implementor is likely to
write and what the spec describes. This change changes the test to
ancestors-or-self, and removes the slot element from the list of
conditions so that it is possible to reach the second sub-item for slot
elements.

The edit above was trying to specify the proposal in
#3699 (comment). I
found a case where I had intended to match that proposal but made an
error: the handling of <slot> descendants in the second sub-item was
intended to look at their resolved directionality, not their auto
directionality. (And this is a simpler test, since the concept always
exists, so there's no need to test it for null.) This corrects that
error.

I believe this combination of changes matches the interaction of these
pieces that I intended to write: slot elements with a dir attribute (and
their descendants) are skipped, whereas slot elements without a dir
attribute provide the strong directionality from their host.
  • Loading branch information
dbaron authored Oct 24, 2023
1 parent 11114d0 commit 2e54ab5
Showing 1 changed file with 5 additions and 17 deletions.
22 changes: 5 additions & 17 deletions source
Original file line number Diff line number Diff line change
Expand Up @@ -13668,36 +13668,24 @@ Transport Protocol">HTTP&lt;/abbr> today.&lt;/p></code></pre> <!-- DO NOT REWRAP

<ol>
<li>
<p>If <var>descendant</var> has an ancestor element that is a descendant of <var>element</var>
and is also one of</p>
<p>If <var>descendant</var>, or any of its ancestor elements that are descendants of
<var>element</var>, is one of</p>

<ul class="brief">
<li>a <code>bdi</code> element</li>
<li>a <code>script</code> element</li>
<li>a <code>style</code> element</li>
<li>a <code>textarea</code> element</li>
<li>a <code>slot</code> element whose <span>root</span> is a <span>shadow
root</span></li>
<li>an element whose <code data-x="attr-dir">dir</code> attribute is not in the <span
data-x="attr-dir-undefined-state">undefined</span> state</li>
</ul>

<p>then <span>continue</span>.</p>
</li>

<li>
<p>If <var>descendant</var> is a <code>slot</code> element whose <span>root</span> is a
<span>shadow root</span>, then:</p>

<ol>
<li><p>Let <var>result</var> be the <span>auto directionality</span> of
<var>descendant</var>.</p></li>.

<li><p>If <var>result</var> is not null, then return <var>result</var>.</p></li>

<li><p>Return '<span data-x="concept-ltr">ltr</span>'.</p></li>
</ol>
</li>
<li><p>If <var>descendant</var> is a <code>slot</code> element whose <span>root</span> is a
<span>shadow root</span>, then return the <span data-x="the
directionality">directionality</span> of <var>descendant</var>.</p></li>

<li><p>If <var>descendant</var> is not a <code>Text</code> node, then
<span>continue</span>.</p></li>
Expand Down

0 comments on commit 2e54ab5

Please sign in to comment.