Skip to content

Prevent infinite loop in revealing algorithms #11457

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
120 changes: 66 additions & 54 deletions source
Original file line number Diff line number Diff line change
Expand Up @@ -62186,35 +62186,6 @@ interface <dfn interface>HTMLDetailsElement</dfn> : <span>HTMLElement</span> {

</div>

<p>The <dfn>ancestor details revealing algorithm</dfn> is to run the following steps on
<var>currentNode</var>:</p>

<ol>
<li>
<p>While <var>currentNode</var> has a parent node within the <span>flat tree</span>:</p>

<ol>
<li>
<p>If <var>currentNode</var> is slotted into the second slot of a <code>details</code>
element:</p>

<ol>
<li><p>Set <var>currentNode</var> to the <code>details</code> element which
<var>currentNode</var> is slotted into.</p></li>

<li><p>If the <code data-x="attr-details-open">open</code> attribute is not set on
<var>currentNode</var>, then <span data-x="concept-element-attributes-set-value">set</span>
the <code data-x="attr-details-open">open</code> attribute on <var>currentNode</var> to the
empty string.</p></li>
</ol>
</li>

<li><p>Otherwise, set <var>currentNode</var> to the parent node of
<var>currentNode</var> within the <span>flat tree</span>.</p></li>
</ol>
</li>
</ol>

<div class="example">

<p>The following example shows the <code>details</code> element being used to hide technical
Expand Down Expand Up @@ -80398,8 +80369,7 @@ END:VCARD</pre>
data-x="navigate-fragid">fragment navigation</span>. When these features attempt to scroll to a
target which is in the element's subtree, the user agent will remove the <code
data-x="attr-hidden">hidden</code> attribute in order to reveal the content before scrolling to
it by running the <span>ancestor hidden-until-found revealing algorithm</span> on the target
node.</p>
it by running the <span>ancestor revealing algorithm</span> on the target node.</p>

<div w-nodev>

Expand Down Expand Up @@ -80554,30 +80524,82 @@ END:VCARD</pre>
string.</p></li>
</ol>

<p>The <dfn>ancestor hidden-until-found revealing algorithm</dfn> is to run the following steps on
<var>currentNode</var>:</p>
<p>An <dfn>ancestor reveal pair</dfn> is a <span>tuple</span> consisting of a <dfn
data-x="ancestor-reveal-pair-node">node</dfn> and a <dfn
data-x="ancestor-reveal-pair-string">string</dfn>.</p>

<p>The <dfn>ancestor revealing algorithm</dfn> given a node <var>target</var> is:</p>

<ol>
<li><p>Let <var>ancestorsToReveal</var> be « ».</p></li>

<li><p>Let <var>ancestor</var> be <var>target</var>.</p></li>

<li>
<p>While <var>currentNode</var> has a parent node within the <span>flat tree</span>:</p>
<p>While <var>ancestor</var> has a parent node within the <span>flat tree</span>:</p>

<ol>
<li><p>If <var>ancestor</var> has a <code data-x="attr-hidden">hidden</code> attribute in the
<span data-x="attr-hidden-until-found-state">Hidden Until Found</span> state, then <span
data-x="list append">append</span> (<var>ancestor</var>, "<code data-x="">until-found</code>")
to <var>ancestorsToReveal</var>.</p></li>

<li><p>If <var>ancestor</var> is slotted into the second slot of a <code>details</code>
element which does not have an <code data-x="attr-details-open">open</code> attribute, then
<span data-x="list append">append</span> (<var>ancestor</var>'s parent node, "<code
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<span data-x="list append">append</span> (the <code>details</code>, "<code
<span data-x="list append">append</span> (<var>ancestor</var>, "<code

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ancestor is not the details element though, its slotted into the details element. I changed it to ancestor's parent which is the details element. How does that look?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh I see, that works I think.

data-x="">details</code>") to <var>ancestorsToReveal</var>.</p></li>

<li><p>Set <var>ancestor</var> to the parent node of <var>ancestor</var> within the
<span>flat tree</span>.</p></li>
</ol>
</li>

<li>
<p>For each <var>ancestorToRevealPair</var> of <var>ancestorsToReveal</var>:</p>

<ol>
<li><p>Let (<var>ancestorToReveal</var>, <var>revealType</var>) be
<var>ancestorToRevealPair</var>.</p></li>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I meant you could do

For each (a, b) of list:


<li><p>If <var>ancestorToReveal</var> is not <span>connected</span>, then return.</p></li>

<li>
<p>If <var>currentNode</var> has the <code data-x="attr-hidden">hidden</code> attribute in the
<span data-x="attr-hidden-until-found-state">Hidden Until Found</span> state, then:</p>
<p>If <var>revealType</var> is "<code data-x="">until-found</code>":</p>

<ol>
<li><p>If <var>ancestorToReveal</var>'s <code data-x="attr-hidden">hidden</code> attribute is
not in the <span data-x="attr-hidden-until-found-state">Hidden Until Found</span> state, then
return.</p></li>

<li><p><span data-x="concept-event-fire">Fire an event</span> named <code
data-x="event-beforematch">beforematch</code> at <var>currentNode</var> with the <code
data-x="event-beforematch">beforematch</code> at <var>ancestorToReveal</var> with the <code
data-x="dom-Event-bubbles">bubbles</code> attribute initialized to true.</p></li>

<li><p>If <var>ancestorToReveal</var> is not <span>connected</span>, then return.</p></li>

<li><p>If <var>ancestorToReveal</var>'s <code data-x="attr-hidden">hidden</code> attribute is
not in the <span data-x="attr-hidden-until-found-state">Hidden Until Found</span> state, then
return.</p></li>

<li><p>Remove the <code data-x="attr-hidden">hidden</code> attribute from
<var>currentNode</var>.</p></li>
<var>ancestorToReveal</var>.</p></li>
</ol>
</li>
<li>

<li><p>Set <var>currentNode</var> to the parent node of <var>currentNode</var> within the
<span>flat tree</span>.</p></li>
<li>
<p>Otherwise:</p>

<ol>
<li><p><span>Assert</span>: <var>revealType</var> is "<code
data-x="">details</code>".</p></li>

<li><p>If <var>ancestorToReveal</var> has an <code data-x="attr-details-open">open</code>
attribute, then return.</p></li>

<li><p>Set <var>ancestorToReveal</var>'s <code data-x="attr-details-open">open</code>
attribute to the empty string.</p></li>
</ol>
</li>
</ol>
</li>
</ol>
Expand Down Expand Up @@ -84451,15 +84473,8 @@ body { display:none }
match</span>.</p></li>

<li><p><span>Queue a global task</span> on the <span>user interaction task source</span> given
<var>node</var>'s <span>relevant global object</span> to run the following steps:</p>

<ol>
<li><p>Run the <span>ancestor details revealing algorithm</span> on <var>node</var>.</p></li>

<li><p>Run the <span>ancestor hidden-until-found revealing algorithm</span> on
<var>node</var>.</p></li>
</ol>
</li>
<var>node</var>'s <span>relevant global object</span> to run the <span>ancestor revealing
algorithm</span> on <var>node</var>.</p></li>
</ol>

<p class="warning">
Expand Down Expand Up @@ -106727,10 +106742,7 @@ location.href = '#foo';</code></pre>

<li><p>Set <var>document</var>'s <span>target element</span> to <var>target</var>.</p></li>

<li><p>Run the <span>ancestor details revealing algorithm</span> on <var>target</var>.</p></li>

<li><p>Run the <span>ancestor hidden-until-found revealing algorithm</span> on
<var>target</var>.</p></li>
<li><p>Run the <span>ancestor revealing algorithm</span> on <var>target</var>.</p></li>

<li><p><span data-x="scroll a target into view">Scroll <var>target</var> into view</span>,
with <i>behavior</i> set to "auto", <i>block</i> set to "start", and <i>inline</i>
Expand Down