Skip to content

Commit 56e1d94

Browse files
committed
[selectors-4] Align :user-invalid/valid with HTML spec #9308 #9257
1 parent 3ccec1d commit 56e1d94

File tree

1 file changed

+24
-23
lines changed

1 file changed

+24
-23
lines changed

selectors-4/Overview.bs

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2874,29 +2874,36 @@ The User-interaction Pseudo-classes: '':user-valid'' and '':user-invalid''</h4>
28742874
and the <dfn id="user-valid-pseudo">:user-valid</dfn> pseudo-classes
28752875
represent an element with incorrect or correct input, respectively,
28762876
but only <em>after</em> the user has significantly interacted with it.
2877+
Their purpose is to help the user identify mistakes in their input.
28772878

2878-
The '':user-invalid'' pseudo-class
2879-
must match an '':invalid'', '':out-of-range'', or
2880-
blank-but-'':required'' elements between the time the user has attempted
2881-
to submit the form and before the user has interacted again with the
2882-
form element.
2883-
2884-
The '':user-valid'' pseudo-class must match a '':valid'' element between the
2885-
time the user has attempted to submit the form and before the user has
2886-
interacted again with the form element.
2887-
2888-
User-agents may allow them to match such elements at other times,
2879+
These pseudo-classes must at least match their respective elements
2880+
after the user has attempted to submit the form
2881+
and before the user has interacted again with the input element
2882+
or reset the form.
2883+
They may also match at other times,
28892884
as would be appropriate for highlighting an error to the user.
2890-
For example, a UA may choose to have '':user-invalid'' match an
2891-
'':invalid'' element once the user has typed some text into it and
2892-
changed the focus to another element, and to stop matching only after
2885+
For example, '':user-invalid''
2886+
could start matching an '':invalid'' input element
2887+
once the user has changed its value
2888+
and focus has moved to another element;
2889+
or stop matching only after
28932890
the user has successfully corrected the input.
28942891

2892+
Host languages may define more precise matching rules
2893+
or defer to platform conventions;
2894+
otherwise the exact behavior is UA-defined.
2895+
Regardless,
2896+
the '':user-invalid'' pseudo-class must only match '':invalid'' elements;
2897+
and the '':user-valid'' pseudo-class must only match '':valid'' elements.
2898+
See the <a spec=html lt=":user-invalid" selector>HTML specification</a>
2899+
for the specific rules pertaining to HTML elements. [[!HTML]]
2900+
28952901
<div class='example'>
2896-
For example, the input in the following document fragment
2902+
For example, the <{input}> element in the following document fragment
28972903
would match '':invalid'' as soon as the page is loaded
2898-
(because it the initial value violates the max-constraint),
2899-
but it won't match '':user-invalid'' until the user significantly interacts with the element,
2904+
(because the <{input}>'s initial value violates its max constraint)
2905+
but it won't match '':user-invalid''
2906+
until the user significantly interacts with the input field
29002907
or attempts to submit the form it's part of.
29012908

29022909
<pre>
@@ -2910,12 +2917,6 @@ The User-interaction Pseudo-classes: '':user-valid'' and '':user-invalid''</h4>
29102917
</pre>
29112918
</div>
29122919

2913-
Issue: Cross-check with <a href="https://developer.mozilla.org/en-US/docs/Web/CSS/%3A-moz-ui-invalid">'':-moz-ui-invalid''</a>.
2914-
2915-
Issue: Evaluate proposed <a href="https://lists.w3.org/Archives/Public/www-style/2014Feb/0511.html">:dirty pseudo-class</a>
2916-
2917-
Issue: Clarify that this (and '':invalid''/'':valid'') can apply to form and fieldset elements.
2918-
29192920
<h2 id="structural-pseudos">
29202921
Tree-Structural pseudo-classes</h2>
29212922

0 commit comments

Comments
 (0)