Skip to content

Commit b80f5ba

Browse files
committed
Added :user-error to the validity pseudoclasses, and reworked the wording of the section to make it clearer.
1 parent fe326a1 commit b80f5ba

2 files changed

Lines changed: 120 additions & 46 deletions

File tree

selectors4/Overview.html

Lines changed: 74 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -319,8 +319,8 @@ <h2 class="no-num no-toc" id=contents>Table of Contents</h2>
319319
default option pseudo-class ‘<code class=css>:default</code></a>
320320

321321
<li><a href="#validity-pseudos"><span class=secno>11.5. </span> The
322-
validity pseudo-classes<code class=css>:valid</code>’ and
323-
<code class=css>:invalid</code></a>
322+
validity pseudo-classes: <code>:valid</code>, <code>:invalid</code>,
323+
and <code>:user-error</code></a>
324324

325325
<li><a href="#range-pseudos"><span class=secno>11.6. </span> The range
326326
pseudo-classes ‘<code class=css>:in-range</code>’ and ‘<code
@@ -2701,25 +2701,64 @@ <h3 id=default-pseudo><span class=secno>11.4. </span> The default option
27012701
a selection of pizza toppings for example.
27022702

27032703
<h3 id=validity-pseudos><span class=secno>11.5. </span> The validity
2704-
pseudo-classes ’‘<code class=css>:valid</code>’‘<code class=css>
2705-
and </code>’‘<code class=css>:invalid</code>’‘<code
2706-
class=css></code></h3>
2704+
pseudo-classes: <a href="#valid-pseudo"><code>:valid</code></a>, <a
2705+
href="#invalid-pseudo"><code>:invalid</code></a>, and <a
2706+
href="#user-error-pseudo"><code>:user-error</code></a></h3>
27072707

2708-
<p>An element is <code id=valid-pseudo>:valid</code> or <code
2709-
id=invalid-pseudo>:invalid</code> when its contents or value is,
2708+
<p> An element is <dfn id=valid-pseudo>:valid</dfn> or <dfn
2709+
id=invalid-pseudo>:invalid</dfn> when its contents or value is,
27102710
respectively, valid or invalid with respect to data validity semantics
27112711
defined by the document language (e.g. [[XFORMS10]] or <a href="#HTML5"
2712-
rel=biblioentry>[HTML5]<!--{{HTML5}}--></a>). An element which lacks data
2713-
validity semantics is neither <code>:valid</code> nor
2714-
<code>:invalid</code>. This is different from an element which otherwise
2715-
has no constraints. Such an element would always be <code>:valid</code>.
2716-
For example, a text input field with no constraints would always be
2717-
<code>:valid</code>.
2712+
rel=biblioentry>[HTML5]<!--{{HTML5}}--></a>).
2713+
2714+
<p> Note that there is a difference between an element which has no
2715+
constraints, and thus would always be <a
2716+
href="#valid-pseudo"><code>:valid</code></a>, and one which has no data
2717+
validity semantics at all, and thus is neither <a
2718+
href="#valid-pseudo"><code>:valid</code></a> nor <a
2719+
href="#invalid-pseudo"><code>:invalid</code></a>. In HTML, for example, an
2720+
<code>&lt;input type="text"></code> element may have no constraints, but a
2721+
<code>&lt;p></code> element has no validity semantics at all, and so it
2722+
never matches either of these pseudoclasses.
2723+
2724+
<p> The <dfn id=user-error-pseudo>:user-error</dfn> pseudo-class matches
2725+
the same elements as <a href="#invalid-pseudo"><code>:invalid</code></a>,
2726+
but it only does so after the user has interacted with them. The <a
2727+
href="#user-error-pseudo"><code>:user-error</code></a> pseudo-class must
2728+
match elements that are invalid after the user attempts to submit the form
2729+
containing them. User-agents may allow it to match invalid elements
2730+
earlier, if they determine (in a UA-specific manner) that the user has
2731+
"significantly interacted" with them.
2732+
2733+
<div class=example>
2734+
<p> For example, the input in the following document fragment would match
2735+
<a href="#invalid-pseudo"><code>:invalid</code></a> as soon as the page
2736+
is loaded (because it’s empty, which violates the "required"
2737+
constraint), but it won't match <a
2738+
href="#user-error-pseudo"><code>:user-error</code></a> until the user
2739+
significantly interacts with the element, or attempts to submit the form
2740+
it's part of.
2741+
2742+
<pre><!--
2743+
-->&lt;form>
2744+
<!--
2745+
--> &lt;label>
2746+
<!--
2747+
--> First Name:
2748+
<!--
2749+
--> &lt;input name='first-name' required value=''>
2750+
<!--
2751+
--> &lt;/label>
2752+
<!--
2753+
--> ...
2754+
<!--
2755+
-->&lt;/form>&lt;/pre>
2756+
</pre>
2757+
</div>
27182758

27192759
<h3 id=range-pseudos><span class=secno>11.6. </span> The range
2720-
pseudo-classes ’‘<code class=css>:in-range</code>’‘<code
2721-
class=css> and </code>’‘<code
2722-
class=css>:out-of-range</code>’‘<code class=css></code></h3>
2760+
pseudo-classes ‘<code class=css>:in-range</code>’ and ‘<code
2761+
class=css>:out-of-range</code></h3>
27232762

27242763
<p>The <code id=in-range-psuedo>:in-range</code> and <code
27252764
id=out-of-range-pseudo>:out-of-range</code> pseudo-classes apply only to
@@ -2735,9 +2774,8 @@ <h3 id=range-pseudos><span class=secno>11.6. </span> The range
27352774
"C".
27362775

27372776
<h3 id=opt-pseudos><span class=secno>11.7. </span> The optionality
2738-
pseudo-classes ’‘<code class=css>:required</code>’‘<code
2739-
class=css> and </code>’‘<code class=css>:optional</code>’‘<code
2740-
class=css></code></h3>
2777+
pseudo-classes ‘<code class=css>:required</code>’ and ‘<code
2778+
class=css>:optional</code></h3>
27412779

27422780
<p>A form element is <code id=required-pseudo>:required</code> or <code
27432781
id=optional-pseudo>:optional</code> if a value for it is, respectively,
@@ -2746,15 +2784,16 @@ <h3 id=opt-pseudos><span class=secno>11.7. </span> The optionality
27462784
optional.
27472785

27482786
<h3 id=user-error-pseudos><span class=secno>11.8. </span> The
2749-
incorrect-input pseudo-class ’‘<code
2750-
class=css>:user-error</code>’‘<code class=css></code></h3>
2751-
2752-
<p>The <code id=user-error-pseudo>:user-error</code> pseudo-element is
2753-
intended to represent an input element with incorrect input <em>after</em>
2754-
the user has interacted with it and attempted to input data into it. The
2755-
exact rules for when it matches are UA-dependent; however it must match
2756-
every invalid, out-of-range, or empty-but-required form element between
2757-
the time the user has attempted to submit the form and before the user has
2787+
incorrect-input pseudo-class ‘<a href="#user-error-pseudo"><code
2788+
class=css>:user-error</code></a></h3>
2789+
2790+
<p>The <a href="#user-error-pseudo"><code
2791+
id=user-error-pseudo>:user-error</code></a> pseudo-element is intended to
2792+
represent an input element with incorrect input <em>after</em> the user
2793+
has interacted with it and attempted to input data into it. The exact
2794+
rules for when it matches are UA-dependent; however it must match every
2795+
invalid, out-of-range, or empty-but-required form element between the time
2796+
the user has attempted to submit the form and before the user has
27582797
interacted again with the form element, and may match such form elements
27592798
at other times.
27602799

@@ -2763,9 +2802,8 @@ <h3 id=user-error-pseudos><span class=secno>11.8. </span> The
27632802
description</a> do we want to spec here? Or put as examples?
27642803

27652804
<h3 id=rw-pseudos><span class=secno>11.9. </span> The mutability
2766-
pseudo-classes ’‘<code class=css>:read-only</code>’‘<code
2767-
class=css> and </code>’‘<code class=css>:read-write</code>’‘<code
2768-
class=css></code></h3>
2805+
pseudo-classes ‘<code class=css>:read-only</code>’ and ‘<code
2806+
class=css>:read-write</code></h3>
27692807

27702808
<p>An element whose contents are not user-alterable is <code
27712809
id=read-only-pseudo>:read-only</code>. However, elements whose contents
@@ -2791,22 +2829,22 @@ <h2 id=structural-pseudos><span class=secno>12. </span> Tree-Structural
27912829
parent. When calculating the position of an element in the list of
27922830
children of its parent, the index numbering starts at 1.
27932831

2794-
<h3 id=root-pseudo><span class=secno>12.1. </span> <code
2795-
class=css>:root</code><code class=css> pseudo-class</code></h3>
2832+
<h3 id=root-pseudo><span class=secno>12.1. </span><code
2833+
class=css>:root</code> pseudo-class</h3>
27962834

27972835
<p>The <code>:root</code> pseudo-class represents an element that is the
27982836
root of the document. In HTML 4, this is always the <code>HTML</code>
27992837
element.
28002838

2801-
<h3 id=nth-child-pseudo><span class=secno>12.2. </span> <code
2802-
class=css>:nth-child()</code><code class=css> pseudo-class</code></h3>
2839+
<h3 id=nth-child-pseudo><span class=secno>12.2. </span><code
2840+
class=css>:nth-child()</code> pseudo-class</h3>
28032841

28042842
<p>The <code>:nth-child(<var>a</var><code>n</code>+<var>b</var>)</code>
28052843
pseudo-class notation represents an element that has
28062844
<var>a</var><code>n</code>+<var>b</var>-1 siblings <strong>before</strong>
28072845
it in the document tree, for any positive integer or zero value of
28082846
<code>n</code>, and has a parent element. For values of <var>a</var> and
2809-
<var>b</var> greater than zero, this effectively divides the elements
2847+
<var>b</var> greater than zero, this effectively divides the element's
28102848
children into groups of <var>a</var> elements (the last group taking the
28112849
remainder), and selecting the <var>b</var>th element of each group. For
28122850
example, this allows the selectors to address every other row in a table,

selectors4/Overview.src.html

Lines changed: 46 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1959,17 +1959,53 @@ <h3 id="default-pseudo">
19591959
like a selection of pizza toppings for example.
19601960

19611961
<h3 id="validity-pseudos">
1962-
The validity pseudo-classes '':valid'' and '':invalid''</h3>
1962+
The validity pseudo-classes: <code>:valid</code>, <code>:invalid</code>, and <code>:user-error</code></h3>
19631963

1964-
<p>An element is <code id="valid-pseudo">:valid</code> or
1965-
<code id="invalid-pseudo">:invalid</code> when its contents or
1966-
value is, respectively, valid or invalid with respect to data validity
1967-
semantics defined by the document language (e.g. [[XFORMS10]] or [[HTML5]]).
1968-
An element which lacks data validity semantics is neither <code>:valid</code>
1969-
nor <code>:invalid</code>. This is different from an element which
1970-
otherwise has no constraints. Such an element would always be
1971-
<code>:valid</code>. For example, a text input field with no constraints
1972-
would always be <code>:valid</code>.
1964+
<p>
1965+
An element is <dfn id="valid-pseudo">:valid</dfn>
1966+
or <dfn id="invalid-pseudo">:invalid</dfn>
1967+
when its contents or value is, respectively,
1968+
valid or invalid with respect to data validity semantics defined by the document language
1969+
(e.g. [[XFORMS10]] or [[HTML5]]).
1970+
1971+
<p>
1972+
Note that there is a difference between an element which has no constraints,
1973+
and thus would always be <code>:valid</code>,
1974+
and one which has no data validity semantics at all,
1975+
and thus is neither <code>:valid</code> nor <code>:invalid</code>.
1976+
In HTML, for example, an <code>&lt;input type="text"></code> element may have no constraints,
1977+
but a <code>&lt;p></code> element has no validity semantics at all,
1978+
and so it never matches either of these pseudoclasses.
1979+
1980+
<p>
1981+
The <dfn id="user-error-pseudo">:user-error</dfn> pseudo-class
1982+
matches the same elements as <code>:invalid</code>,
1983+
but it only does so after the user has interacted with them.
1984+
The <code>:user-error</code> pseudo-class must match elements that are invalid
1985+
after the user attempts to submit the form containing them.
1986+
User-agents may allow it to match invalid elements earlier,
1987+
if they determine
1988+
(in a UA-specific manner)
1989+
that the user has "significantly interacted" with them.
1990+
1991+
<div class='example'>
1992+
<p>
1993+
For example, the input in the following document fragment
1994+
would match <code>:invalid</code> as soon as the page is loaded
1995+
(because it's empty, which violates the "required" constraint),
1996+
but it won't match <code>:user-error</code> until the user significantly interacts with the element,
1997+
or attempts to submit the form it's part of.
1998+
1999+
<pre><!--
2000+
-->&lt;form>&#xa;<!--
2001+
--> &lt;label>&#xa;<!--
2002+
--> First Name:&#xa;<!--
2003+
--> &lt;input name='first-name' required value=''>&#xa;<!--
2004+
--> &lt;/label>&#xa;<!--
2005+
--> ...&#xa;<!--
2006+
-->&lt;/form>&lt;/pre>
2007+
</div>
2008+
19732009

19742010
<h3 id="range-pseudos">
19752011
The range pseudo-classes '':in-range'' and '':out-of-range''</h3>

0 commit comments

Comments
 (0)