Skip to content

Commit 9d0024d

Browse files
committed
[selectors] Clarify that the 'match if descendants match' user-input pseudos work on the flat tree, and work if a non-element node matches (like hovering over text).
1 parent b1917ca commit 9d0024d

File tree

1 file changed

+25
-16
lines changed

1 file changed

+25
-16
lines changed

selectors/Overview.bs

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -282,8 +282,8 @@ Selectors Overview</h2>
282282
<td>2
283283
<tr>
284284
<td><code>E:focus-ring</code>
285-
<td>an E element that has user input focus,
286-
and the UA has determined that a focus ring or other indicator
285+
<td>an E element that has user input focus,
286+
and the UA has determined that a focus ring or other indicator
287287
should be drawn for that element
288288
<td>[[#useraction-pseudos]]
289289
<td>4
@@ -1989,7 +1989,10 @@ The Pointer Hover Pseudo-class: '':hover''</h3>
19891989
(e.g., a pen device that does not detect hovering)
19901990
are still conforming.
19911991

1992-
An element also matches '':hover'' if one of its <a>shadow-including descendants</a> matches '':hover''.
1992+
An element also matches '':hover''
1993+
if one of its descendants in the <a>flat tree</a>
1994+
(including non-element nodes, such as text nodes)
1995+
matches the above conditions.
19931996

19941997
Document languages may define additional ways in which an element can match '':hover''.
19951998
For example, [[HTML5]] defines a labeled control element as <a href="http://www.whatwg.org/html/selectors.html#selector-hover">matching <code>:hover</code></a>
@@ -2016,7 +2019,10 @@ The Activation Pseudo-class: '':active''</h3>
20162019
which elements can become '':active''.
20172020
For example, [[HTML5]] defines a <a href="http://www.whatwg.org/html/selectors.html#selector-active">list of activatable elements</a>.
20182021

2019-
An element also matches '':active'' if one of its <a>shadow-including descendants</a> matches '':active''.
2022+
An element also matches '':active''
2023+
if one of its descendants in the <a>flat tree</a>
2024+
(including non-element nodes, such as text nodes)
2025+
matches the above conditions.
20202026

20212027
Document languages may define additional ways in which an element can match '':active''.
20222028

@@ -2026,8 +2032,8 @@ The Activation Pseudo-class: '':active''</h3>
20262032
<h3 id="the-focus-pseudo">
20272033
The Input Focus Pseudo-class: '':focus''</h3>
20282034

2029-
The <dfn id='focus-pseudo'>:focus</dfn> pseudo-class applies
2030-
while an element has the focus
2035+
The <dfn id='focus-pseudo'>:focus</dfn> pseudo-class applies
2036+
while an element has the focus
20312037
(accepts keyboard or mouse events, or other forms of input).
20322038

20332039
There may be document language or implementation specific limits on
@@ -2046,26 +2052,26 @@ The Input Focus-Ring Pseudo-class: '':focus-ring''</h3>
20462052
<em>and</em> the UA determines via heuristics
20472053
that the focus should be specially indicated on the element
20482054
(typically via a "focus ring").
2049-
2055+
20502056
<div class=example>
20512057
For example, UAs typically display focus indicators on text elements
20522058
<em>whenever</em> they're focused,
20532059
to draw attention to the fact that keyboard input will affect their contents.
2054-
2060+
20552061
On the other hand, they typically only display focus indicators on buttons
20562062
when they were focused by a keyboard interaction
2057-
(such as tabbing thru the document),
2063+
(such as tabbing thru the document),
20582064
because it's not always immediately obvious where the focus will move
20592065
after such an interaction,
20602066
but not when they were focused by more "obvious" interactions,
20612067
like clicking on the button with a mouse pointer.
20622068
</div>
2063-
2069+
20642070
<div class=advisement>
20652071
Page authors should follow these guidelines
20662072
when deciding whether to use '':focus'' or '':focus-ring''
20672073
to style the focused state of an element:
2068-
2074+
20692075
* If the element has "native" focus indicator behavior
20702076
(such as text fields or buttons),
20712077
use '':focus-ring''.
@@ -2075,7 +2081,7 @@ The Input Focus-Ring Pseudo-class: '':focus-ring''</h3>
20752081
* Otherwise,
20762082
use '':focus-ring''.
20772083
</div>
2078-
2084+
20792085
When UAs choose to specially indicate focus on an element,
20802086
or whether they specially indicate focus at all,
20812087
is UA-dependent.
@@ -2084,12 +2090,12 @@ The Input Focus-Ring Pseudo-class: '':focus-ring''</h3>
20842090
or the same UA on the same OS,
20852091
but with different user settings,
20862092
can make different choices as to when an element matches '':focus-ring''.
2087-
2093+
20882094
<div class=example>
20892095
The following guidelines are suggested heuristics
2090-
for choosing when to apply '':focus-ring''
2096+
for choosing when to apply '':focus-ring''
20912097
to elements without "native" focus ring behavior:
2092-
2098+
20932099
* If the element received focus via a keyboard interaction,
20942100
including indirectly,
20952101
such as triggering a dialog
@@ -2105,7 +2111,10 @@ The Generalized Input Focus Pseudo-class: '':focus-within''</h3>
21052111

21062112
The <dfn id='focus-within-pseudo'>:focus-within</dfn> pseudo-class applies to elements for which the '':focus'' pseudo class applies.
21072113

2108-
An element also matches '':focus-within'' if one of its <a>shadow-including descendants</a> matches '':focus''.
2114+
An element also matches '':focus-within''
2115+
if one of its descendants in the <a>flat tree</a>
2116+
(including non-element nodes, such as text nodes)
2117+
matches the conditions for matching '':focus''.
21092118

21102119
<h3 id="drag-pseudos">
21112120
The Drag-and-Drop Pseudo-class: '':drop'' and '':drop()''</h3>

0 commit comments

Comments
 (0)