Skip to content
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

Handle shadow DOM and <dialog> focusing #7285

Merged
merged 2 commits into from
Nov 18, 2021
Merged
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
62 changes: 32 additions & 30 deletions source
Original file line number Diff line number Diff line change
Expand Up @@ -58168,16 +58168,9 @@ interface <dfn interface>HTMLDialogElement</dfn> : <span>HTMLElement</span> {
<ol>
<li><p>If <var>subject</var> is <span>inert</span>, return.</p></li>

<li>
<p>Let <var>control</var> be the first descendant element of <var>subject</var>, in <span>tree
order</span>, that is not <span>inert</span> and has the <code
data-x="attr-fe-autofocus">autofocus</code> attribute specified.</p>

<p>If there isn't one, then let <var>control</var> be the first non-<span>inert</span>
descendant element of <var>subject</var>, in tree order.
<li><p>Let <var>control</var> be the <span>focus delegate</span> of <var>subject</var>.</p></li>

<p>If there isn't one of those either, then let <var>control</var> be <var>subject</var>.</p>
</li>
<li><p>If <var>control</var> is null, then set <var>control</var> to <var>subject</var>.</p></li>

<li>
<p>Run the <span>focusing steps</span> for <var>control</var>.</p>
Expand Down Expand Up @@ -75060,27 +75053,8 @@ END:VCARD</pre>
<span>currently focused area of a top-level browsing context</span>'s <span>DOM anchor</span>,
then return null.</p></li>

<li><p>Let <var>autofocus delegate</var> be the <span>autofocus delegate</span> for
<var>root</var> given <var>focus trigger</var>.</p></li>

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

<li><p>If <var>focus trigger</var> is "<code data-x="">click</code>", then let <var>possible
focus delegates</var> be the list of all <span>click focusable</span> <span data-x="focusable
area">focusable areas</span> whose <span>DOM anchor</span> is a <span>shadow-including
descendant</span> of <var>root</var>.</p></li>

<li><p>Otherwise, let <var>possible focus delegates</var> be the list of all <span
data-x="focusable area">focusable areas</span> whose <span>DOM anchor</span> is a
<span>shadow-including descendant</span> of <var>root</var>.</p></li>

<li><p>If <var>possible focus delegates</var> is empty, then return null.</p></li>

<li><p>Sort <var>possible focus delegates</var> by <span>shadow-including tree
order</span> of their <span data-x="DOM anchor">DOM anchors</span>.</p></li>

<li><p>Return <var>possible focus delegates</var>[0].</p></li>
<li><p>Return the <span>focus delegate</span> for <var>root</var> given <var>focus
trigger</var>.</p></li>
</ol>

<p class="note">For <span data-x="sequentially focusable">sequential focusability</span>, the
Expand All @@ -75095,6 +75069,34 @@ END:VCARD</pre>
<dd><p>Return null.</p></dd>
</dl>

<p>The <dfn>focus delegate</dfn> for a <var>focus target</var>, given an optional string
<var>focus trigger</var> (default "<code data-x="">other</code>"), is given by the following
steps:</p>

<ol>
<li><p>Let <var>autofocus delegate</var> be the <span>autofocus delegate</span> for
<var>focus target</var> given <var>focus trigger</var>.</p></li>

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

<li><p>If <var>focus trigger</var> is "<code data-x="">click</code>", then let <var>possible
focus delegates</var> be the list of all <span>click focusable</span> <span data-x="focusable
area">focusable areas</span> whose <span>DOM anchor</span> is a <span>shadow-including
descendant</span> of <var>focus target</var>.</p></li>

<li><p>Otherwise, let <var>possible focus delegates</var> be the list of all <span
data-x="focusable area">focusable areas</span> whose <span>DOM anchor</span> is a
Copy link
Contributor

Choose a reason for hiding this comment

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

This "DOM anchor" span doesn't have data-x="DOM anchor", but the "DOM anchor" span below has data-x="DOM anchor". Does it make a difference?

Copy link
Member Author

Choose a reason for hiding this comment

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

It's necessary below because the actual text is DOM anchors with a plural "s". Here it can be inferred based on the text content. https://github.com/whatwg/wattsi/blob/main/Syntax.md for more.

<span>shadow-including descendant</span> of <var>focus target</var>.</p></li>

<li><p>If <var>possible focus delegates</var> is empty, then return null.</p></li>

<li><p>Sort <var>possible focus delegates</var> by <span>shadow-including tree order</span> of
their <span data-x="DOM anchor">DOM anchors</span>.</p></li>

<li><p>Return <var>possible focus delegates</var>[0].</p></li>
</ol>

<p>The <dfn>autofocus delegate</dfn> for a <var>focus target</var> given a <var>focus
trigger</var> is given by the following steps:</p>

Expand Down