Skip to content

Commit

Permalink
Define what tabIndex returns when the tabindex attribute is not set
Browse files Browse the repository at this point in the history
This updates the tabIndex getter's default value to be 0 for a specific
list of element types, instead of the spec's previous "elements that are
focusable". This matches reality better; apart from minor edge cases
all three browser engines match this spec in observable behavior.

Closes whatwg#1786. Closes whatwg#4464. See the focus meta-bug in whatwg#4607 for related
discussions, including on adding an API that actually reflects whether
an element is focusable (like the tabIndex getter was kind-of supposed
to do).

Tests: web-platform-tests/wpt#17657
  • Loading branch information
rakina authored and domenic committed Jul 9, 2019
1 parent e51cf93 commit 15cf23a
Showing 1 changed file with 24 additions and 8 deletions.
32 changes: 24 additions & 8 deletions source
Original file line number Diff line number Diff line change
Expand Up @@ -57394,18 +57394,30 @@ interface <dfn>HTMLDetailsElement</dfn> : <span>HTMLElement</span> {

<div w-nodev>

<p>The <span>activation behavior</span> of <code>summary</code> elements is to run the following
steps:</p>
<p>A <code>summary</code> element is a <dfn>summary for its parent details</dfn> if the following
algorithm returns true:</p>

<ol>
<li><p>If this <code>summary</code> element has no parent node, then return.</p></li>
<li><p>If this <code>summary</code> element has no parent, then return false.</p></li>

<li><p>Let <var>parent</var> be this <code>summary</code> element's parent node.</p>
<li><p>Let <var>parent</var> be this <code>summary</code> element's parent.</p></li>

<li><p>If <var>parent</var> is not a <code>details</code> element, then return.</p>
<li><p>If <var>parent</var> is not a <code>details</code> element, then return false.</p></li>

<li><p>If <var>parent</var>'s first <code>summary</code> element child is not this
<code>summary</code> element, then return.</p></li>
<code>summary</code> element, then return false.</p></li>

<li><p>Return true.</p></li>
</ol>

<p>The <span>activation behavior</span> of <code>summary</code> elements is to run the following
steps:</p>

<ol>
<li><p>If this <code>summary</code> element is not the <span>summary for its parent
details</span>, then return.</p></li>

<li><p>Let <var>parent</var> be this <code>summary</code> element's parent.</p></li>

<li>
<p>If the <code data-x="attr-details-open">open</code> attribute is present on
Expand Down Expand Up @@ -73819,8 +73831,12 @@ END:VCARD</pre>

<p>The <dfn><code data-x="dom-tabIndex">tabIndex</code></dfn> IDL attribute must
<span>reflect</span> the value of the <code data-x="attr-tabindex">tabindex</code> content
attribute. Its default value is 0 for elements that are focusable and &#x2212;1 for elements that
are not focusable.</p>
attribute. The default value is 0 if the element is an <code>a</code>, <code>area</code>,
<code>button</code>, <code>iframe</code>, <code>input</code>, <code>select</code>, or
<code>textarea</code> element, or is a <code>summary</code> element that is a <span>summary for
its parent details</span>. The default value is &#x2212;1 otherwise.</p>

<p class="note">The varying default value based on element type is a historical artifact.</p>

</div>

Expand Down

0 comments on commit 15cf23a

Please sign in to comment.