Skip to content

Commit

Permalink
Handle shadow DOM and <dialog> focusing
Browse files Browse the repository at this point in the history
Closes whatwg#2393, by making <dialog> behave the same as delegatesFocus: they both "delegate focus" to either autofocus="" if it's specified on a (non-shadow-including) descendant, or the first focusable element among their shadow-including descendants if not.
  • Loading branch information
domenic committed Nov 18, 2021
1 parent 10fa46b commit 32a94ad
Showing 1 changed file with 32 additions and 30 deletions.
62 changes: 32 additions & 30 deletions source
Original file line number Diff line number Diff line change
Expand Up @@ -58171,16 +58171,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 @@ -75189,27 +75182,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 @@ -75224,6 +75198,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
<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

0 comments on commit 32a94ad

Please sign in to comment.