Skip to content

Commit b78c97c

Browse files
committed
[selectors-4] Per WG resolution, add the :unchecked pseudo-class. Fold :indeterminate into the same section, and give some host language guidance. #10746
1 parent 93e7cbc commit b78c97c

File tree

1 file changed

+56
-37
lines changed

1 file changed

+56
-37
lines changed

selectors-4/Overview.bs

Lines changed: 56 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -350,17 +350,14 @@ Selectors Overview</h2>
350350
<td>[[#the-default-pseudo]]
351351
<td>3-UI/4
352352
<tr>
353-
<td><code>E:checked</code>
353+
<td><code>E:checked</code><br><code>E:unchecked</code><br><code>E:indeterminate</code>
354354
<td>a user interface element E that is checked/selected
355-
(for instance a radio-button or checkbox)
356-
<td>[[#checked]]
355+
(for instance a radio-button or checkbox),
356+
unchecked,
357+
or in an indeterminate state
358+
(neither checked nor unchecked)
359+
<td>[[#input-value-states]]
357360
<td>3
358-
<tr>
359-
<td><code>E:indeterminate</code>
360-
<td>a user interface element E that is in an indeterminate state
361-
(neither checked nor unchecked)
362-
<td>[[#indeterminate]]
363-
<td>4
364361
<tr>
365362
<td><code>E:valid</code><br><code>E:invalid</code>
366363
<td>a user-input element E that meets, or doesn't, its data validity semantics
@@ -2809,42 +2806,64 @@ The Default-option Pseudo-class: '':default''</h4>
28092806
<h3 id="input-value-states">
28102807
Input Value States</h3>
28112808

2812-
<h4 id="checked">
2813-
The Selected-option Pseudo-class: '':checked''</h4>
2809+
<h4 id="checked" oldids="indeterminate">
2810+
The Selected-option Pseudo-classes: '':checked'', '':unchecked'', and '':indeterminate''</h4>
2811+
2812+
Radio and checkbox elements can be toggled by the user,
2813+
and some menu items are “checked” when the user selects them.
2814+
This state is reflected by the <dfn export>input value pseudo-classes</dfn>.
28142815

2815-
Radio and checkbox elements can be toggled by the user.
2816-
Some menu items are “checked” when the user selects them.
28172816
When such elements are toggled “on”
28182817
the <dfn id='checked-pseudo'>:checked</dfn> pseudo-class applies.
28192818
For example, [[HTML5]] defines that <a href="https://html.spec.whatwg.org/multipage/semantics-other.html#selector-checked">checked checkboxes, radio buttons, and selected <code>&lt;option></code> elements</a> match '':checked''.
2819+
Similarly, when such elements are toggled “off”,
2820+
the <dfn id='unchecked-pseudo'>:unchecked</dfn> pseudo-class applies.
2821+
2822+
If an element that <em>could</em> match '':checked'' or '':unchecked''
2823+
is neither "on" nor "off",
2824+
the <dfn id='indeterminate-pseudo'>:indeterminate</dfn> pseudo-class applies.
2825+
'':indeterminate'' also matches elements which do not have a notion of being "checked",
2826+
but whose "value" is still in an indeterminate state,
2827+
such as a progress meter whose progress percentage is unknown.
2828+
2829+
These three pseudo-classes are mutually exclusive;
2830+
an element can only match at most one of them at a time.
2831+
(And might match none,
2832+
if the concept of being "checked" doesn't apply to them.)
2833+
If the "indeterminate" concept is not mutually exclusive
2834+
with the "checked"/"unchecked" concept in a host language
2835+
(for example, in HTML a checkbox's "indeterminate" state is a separate boolean
2836+
from its "checked" state boolean),
2837+
being indeterminate wins over being checked/unchecked
2838+
for the purpose of matching these pseudo-classes.
28202839

2821-
While the '':checked'' pseudo-class is dynamic in nature,
2822-
and can altered by user action,
2823-
since it can also be based on the presence of semantic attributes in the document
2824-
(such as the <code>selected</code> and <code>checked</code> attributes in [[HTML5]]),
2825-
it applies to all media.
2826-
2827-
<div class="example">
2828-
An unchecked checkbox can be selected by using the negation
2829-
pseudo-class:
2830-
2831-
<pre>input[type=checkbox]:not(:checked)</pre>
2840+
<div class=example>
2841+
For example, in HTML:
2842+
2843+
* Checkboxes match '':indeterminate''
2844+
if their {{HTMLInputElement/indeterminate}} property is true;
2845+
otherwise, they match '':checked'' or '':unchecked''
2846+
depending on their {{HTMLInputElement/checked}} property.
2847+
* Radio buttons match '':checked'' if their {{HTMLInputElement/checked}} property is true.
2848+
Otherwise, they match '':unchecked'' if they're in a radio group
2849+
that contains a '':checked'' radio button.
2850+
Otherwise (their {{HTMLInputElement/checked}} property is false,
2851+
but they're alone or in a radio group with no checked radio button),
2852+
they match '':indeterminate''.
2853+
* <{option}> elements within a <{select}>
2854+
match '':checked'' or '':unchecked''
2855+
depending on their {{HTMLOptionElement/selected}} property.
2856+
(They're never '':indeterminate''.)
2857+
* <{progress}> elements match '':indeterminate''
2858+
if they lack a <code>value</code> attribute
28322859
</div>
28332860

2834-
<h4 id="indeterminate">
2835-
The Indeterminate-value Pseudo-class: '':indeterminate''</h4>
2836-
2837-
The <dfn id='indeterminate-pseudo'>:indeterminate</dfn> pseudo-class applies to UI elements whose
2838-
value is in an indeterminate state.
2839-
For example, radio and checkbox elements can be toggled between checked and unchecked states,
2840-
but are sometimes in an indeterminate state, neither checked nor unchecked.
2841-
Similarly a progress meter can be in an indeterminate state when the percent completion is unknown.
2842-
For example, [[HTML5]] defines how <a href="https://html.spec.whatwg.org/multipage/semantics-other.html#selector-indeterminate">checkboxes</a> can be made to match '':indeterminate''.
2861+
While the [=input value pseudo-classes=] are dynamic in nature,
2862+
and can altered by user action,
2863+
since they can also be based on the presence of semantic attributes in the document
2864+
(such as the <code>selected</code> and <code>checked</code> attributes in [[HTML5]]),
2865+
they apply to all media.
28432866

2844-
Like the '':checked'' pseudo-class, '':indeterminate''
2845-
applies to all media. Components of a radio-group initialized with no
2846-
pre-selected choice, for example, would be '':indeterminate''
2847-
even in a static display.
28482867

28492868
<h3 id='ui-validity'>
28502869
Input Value-checking</h3>

0 commit comments

Comments
 (0)