Skip to content

Commit 783cd0c

Browse files
committed
Tweak :user-error definition and give it its own section: it's more than about just :invalid elements, so shouldn't be grouped with those. Also maintain the normative statement about elements that match neither :valid nor :invalid.
--HG-- extra : rebase_source : 8cdc2a8382e2fb495db57be31e16a5d10310da5d
1 parent 93a0ed4 commit 783cd0c

2 files changed

Lines changed: 146 additions & 98 deletions

File tree

selectors4/Overview.html

Lines changed: 87 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@
1919

2020
<h1 id=title>Selectors Level 4</h1>
2121

22-
<h2 class="no-num no-toc" id=longstatus-date>Editor's Draft 14 August 2012</h2>
22+
<h2 class="no-num no-toc" id=longstatus-date>Editor's Draft 16 August 2012</h2>
2323

2424
<dl>
2525
<dt>This version: <!--
26-
<dd><a href="http://www.w3.org/TR/2012/ED-selectors4-20120814/">
27-
http://www.w3.org/TR/2012/WD-selectors4-20120814/</a>
26+
<dd><a href="http://www.w3.org/TR/2012/ED-selectors4-20120816/">
27+
http://www.w3.org/TR/2012/WD-selectors4-20120816/</a>
2828
2929
<dt>Editor's draft:
3030
-->
@@ -320,8 +320,8 @@ <h2 class="no-num no-toc" id=contents>Table of Contents</h2>
320320
default option pseudo-class <code>:default</code></a>
321321

322322
<li><a href="#validity-pseudos"><span class=secno>11.5. </span> The
323-
validity pseudo-classes: <code>:valid</code>, <code>:invalid</code>,
324-
and <code>:user-error</code></a>
323+
validity pseudo-classes: <code>:valid</code> and
324+
<code>:invalid</code></a>
325325

326326
<li><a href="#range-pseudos"><span class=secno>11.6. </span> The range
327327
pseudo-classes <code>:in-range</code> and
@@ -331,7 +331,10 @@ <h2 class="no-num no-toc" id=contents>Table of Contents</h2>
331331
optionality pseudo-classes <code>:required</code> and
332332
<code>:optional</code></a>
333333

334-
<li><a href="#rw-pseudos"><span class=secno>11.8. </span> The mutability
334+
<li><a href="#user-pseudos"><span class=secno>11.8. </span> The
335+
user-interaction pseudo-class <code>:user-error</code></a>
336+
337+
<li><a href="#rw-pseudos"><span class=secno>11.9. </span> The mutability
335338
pseudo-classes <code>:read-only</code> and <code>:read-write</code></a>
336339

337340
</ul>
@@ -1240,14 +1243,14 @@ <h3 id=scoping><span class=secno>3.3. </span> Scoped Selectors</h3>
12401243
href="#scope-pseudo"><code>:scope</code></a> pseudo-class.
12411244

12421245
<div class=example>
1243-
<p> For example, the <code>document.querySelector()</code> function
1244-
defined in <a href="#SELECTORS-API2"
1246+
<p> For example, the <code>element.querySelector()</code> function defined
1247+
in <a href="#SELECTORS-API2"
12451248
rel=biblioentry>[SELECTORS-API2]<!--{{SELECTORS-API2}}--></a> allows the
12461249
author to define a <a
12471250
href="#scope-constrained"><i>scope-constrained</i></a> selector.
12481251

1249-
<p> On the other hand, the <code>document.find()</code> function defined
1250-
in <a href="#SELECTORS-API2"
1252+
<p> On the other hand, the <code>element.find()</code> function defined in
1253+
<a href="#SELECTORS-API2"
12511254
rel=biblioentry>[SELECTORS-API2]<!--{{SELECTORS-API2}}--></a> and the
12521255
selectors within an <a href="#HTML5"
12531256
rel=biblioentry>[HTML5]<!--{{HTML5}}--></a> scoped stylesheet, define <a
@@ -1894,7 +1897,8 @@ <h3 id=attribute-case><span class=secno>6.3. </span> Case-sensitivity</h3>
18941897
has a value of <code>hsides</code>, whether that value is represented as
18951898
<code>hsides</code>, <code>HSIDES</code>, <code>hSides</code>, etc. even
18961899
in an XML environment where attribute values are case-sensitive.
1897-
f<!-- -->[frame=hsides i] { border-style: solid none; }
1900+
1901+
<pre>[frame=hsides i] { border-style: solid none; }</pre>
18981902
</div>
18991903
<!-- plinss notes we may eventually want to choose other normalizations
19001904
for attribute matching; but since there's no normalization scheme
@@ -2787,64 +2791,27 @@ <h3 id=the-default-pseudo><span class=secno>11.4. </span> The default
27872791
selection of pizza toppings for example.
27882792

27892793
<h3 id=validity-pseudos><span class=secno>11.5. </span> The validity
2790-
pseudo-classes: <a href="#valid-pseudo"><code>:valid</code></a>, <a
2791-
href="#invalid-pseudo"><code>:invalid</code></a>, and <a
2792-
href="#user-error-pseudo"><code>:user-error</code></a></h3>
2794+
pseudo-classes: <a href="#valid-pseudo"><code>:valid</code></a> and <a
2795+
href="#invalid-pseudo"><code>:invalid</code></a></h3>
27932796

27942797
<p> An element is <dfn id=valid-pseudo>:valid</dfn> or <dfn
27952798
id=invalid-pseudo>:invalid</dfn> when its contents or value is,
27962799
respectively, valid or invalid with respect to data validity semantics
27972800
defined by the document language (e.g. [[XFORMS10]] or <a href="#HTML5"
2798-
rel=biblioentry>[HTML5]<!--{{HTML5}}--></a>).
2801+
rel=biblioentry>[HTML5]<!--{{HTML5}}--></a>). An element which lacks data
2802+
validity semantics is neither <a
2803+
href="#valid-pseudo"><code>:valid</code></a> nor <a
2804+
href="#invalid-pseudo"><code>:invalid</code></a>.
27992805

2800-
<p> Note that there is a difference between an element which has no
2801-
constraints, and thus would always be <a
2806+
<p class=note> Note that there is a difference between an element which has
2807+
no constraints, and thus would always be <a
28022808
href="#valid-pseudo"><code>:valid</code></a>, and one which has no data
28032809
validity semantics at all, and thus is neither <a
28042810
href="#valid-pseudo"><code>:valid</code></a> nor <a
28052811
href="#invalid-pseudo"><code>:invalid</code></a>. In HTML, for example, an
28062812
<code>&lt;input type="text"></code> element may have no constraints, but a
28072813
<code>&lt;p></code> element has no validity semantics at all, and so it
2808-
never matches either of these pseudoclasses.
2809-
2810-
<p> The <dfn id=user-error-pseudo>:user-error</dfn> pseudo-class matches
2811-
the same elements as <a href="#invalid-pseudo"><code>:invalid</code></a>,
2812-
but it only does so after the user has interacted with them. The <a
2813-
href="#user-error-pseudo"><code>:user-error</code></a> pseudo-class must
2814-
match elements that are invalid after the user attempts to submit the form
2815-
containing them. User-agents may allow it to match invalid elements
2816-
earlier, if they determine (in a UA-specific manner) that the user has
2817-
"significantly interacted" with them.
2818-
2819-
<div class=example>
2820-
<p> For example, the input in the following document fragment would match
2821-
<a href="#invalid-pseudo"><code>:invalid</code></a> as soon as the page
2822-
is loaded (because it’s empty, which violates the "required"
2823-
constraint), but it won't match <a
2824-
href="#user-error-pseudo"><code>:user-error</code></a> until the user
2825-
significantly interacts with the element, or attempts to submit the form
2826-
it's part of.
2827-
2828-
<pre><!--
2829-
-->&lt;form>
2830-
<!--
2831-
--> &lt;label>
2832-
<!--
2833-
--> First Name:
2834-
<!--
2835-
--> &lt;input name='first-name' required value=''>
2836-
<!--
2837-
--> &lt;/label>
2838-
<!--
2839-
--> ...
2840-
<!--
2841-
-->&lt;/form>&lt;/pre>
2842-
</pre>
2843-
</div>
2844-
2845-
<p class=issue> What parts of <a
2846-
href="https://developer.mozilla.org/en-US/docs/CSS/:-moz-ui-invalid">:-moz-ui-invalid
2847-
description</a> do we want to spec here? Or put as examples?
2814+
never matches either of these pseudo-classes.
28482815

28492816
<h3 id=range-pseudos><span class=secno>11.6. </span> The range
28502817
pseudo-classes <a href="#in-range-psuedo"><code>:in-range</code></a> and
@@ -2875,7 +2842,69 @@ <h3 id=opt-pseudos><span class=secno>11.7. </span> The optionality
28752842
submitted. Elements that are not form elements are neither required nor
28762843
optional.
28772844

2878-
<h3 id=rw-pseudos><span class=secno>11.8. </span> The mutability
2845+
<h3 id=user-pseudos><span class=secno>11.8. </span> The user-interaction
2846+
pseudo-class <a href="#user-error-pseudo"><code>:user-error</code></a></h3>
2847+
2848+
<p> The <dfn id=user-error-pseudo>:user-error</dfn> pseudo-class represents
2849+
an input element with incorrect input, but only <em>after</em> the user
2850+
has significantly interacted with it. The <a
2851+
href="#user-error-pseudo"><code>:user-error</code></a> pseudo-class must
2852+
match an <a href="#invalid-pseudo"><code>:invalid</code></a>, <a
2853+
href="#out-of-range-pseudo"><code>:out-of-range</code></a>, or
2854+
empty-but-<a href="#required-pseudo"><code>:required</code></a> form
2855+
element between the time the user has attempted to submit the form and
2856+
before the user has interacted again with the form element. User-agents
2857+
may allow it to match such elements at other times, as would be
2858+
appropriate for highlighting an error to the user. For example, a UA may
2859+
choose to have <a href="#user-error-pseudo"><code>:user-error</code></a>
2860+
match an <a href="#invalid-pseudo"><code>:invalid</code></a> element once
2861+
the user has typed some text into it and changed the focus to another
2862+
element, and to stop matching only after the user has successfully
2863+
corrected the input.
2864+
2865+
<div class=example>
2866+
<p> For example, the input in the following document fragment would match
2867+
<a href="#invalid-pseudo"><code>:invalid</code></a> as soon as the page
2868+
is loaded (because it the initial value violates the max-constraint), but
2869+
it won’t match <a
2870+
href="#user-error-pseudo"><code>:user-error</code></a> until the user
2871+
significantly interacts with the element, or attempts to submit the form
2872+
it's part of.
2873+
2874+
<pre><!--
2875+
-->&lt;form>
2876+
<!--
2877+
--> &lt;label>
2878+
<!--
2879+
--> Volume:
2880+
<!--
2881+
--> &lt;input name='vol' type=number min=0 max=10 value=11>
2882+
<!--
2883+
--> &lt;/label>
2884+
<!--
2885+
--> ...
2886+
<!--
2887+
-->&lt;/form>&lt;/pre>
2888+
</pre>
2889+
</div>
2890+
<!--
2891+
<p class="issue">
2892+
If it's necessary to distinguish between omitted and invalid values,
2893+
<code>:user-invalid</code> and <code>:user-omitted</code> could be used.
2894+
-->
2895+
2896+
<p class=issue> What parts of <a
2897+
href="https://developer.mozilla.org/en-US/docs/CSS/:-moz-ui-invalid">:-moz-ui-invalid
2898+
description</a> do we want to spec here? Or put as examples?
2899+
2900+
<p class=issue> There was a suggestion to have a
2901+
<code>:user-interacted</code> pseudo-class instead of or in addition to
2902+
this one. It's unclear what the criteria would be for matching it,
2903+
however. In particular, it seems unlikely to be a replacement of this one
2904+
if form validation of an untouched form control is not part of the
2905+
criteria.
2906+
2907+
<h3 id=rw-pseudos><span class=secno>11.9. </span> The mutability
28792908
pseudo-classes <a href="#read-only-pseudo"><code>:read-only</code></a> and
28802909
<a href="#read-write-pseudo"><code>:read-write</code></a></h3>
28812910

selectors4/Overview.src.html

Lines changed: 59 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -614,11 +614,11 @@ <h3 id="scoping">
614614
<div class='example'>
615615
<p>
616616
For example,
617-
the <code>document.querySelector()</code> function defined in [[SELECTORS-API2]]
617+
the <code>element.querySelector()</code> function defined in [[SELECTORS-API2]]
618618
allows the author to define a <i>scope-constrained</i> selector.
619619

620620
<p>
621-
On the other hand, the <code>document.find()</code> function defined in [[SELECTORS-API2]]
621+
On the other hand, the <code>element.find()</code> function defined in [[SELECTORS-API2]]
622622
and the selectors within an [[HTML5]] scoped stylesheet,
623623
define <i>scope-contained</i> selectors.
624624
</div>
@@ -1188,8 +1188,7 @@ <h3 id="attribute-case">
11881188
has a value of <code>hsides</code>, whether that value is represented
11891189
as <code>hsides</code>, <code>HSIDES</code>, <code>hSides</code>, etc.
11901190
even in an XML environment where attribute values are case-sensitive.
1191-
f<!-- -->[frame=hsides i] { border-style: solid none; }
1192-
</pre>
1191+
<pre>[frame=hsides i] { border-style: solid none; }</pre>
11931192
</div>
11941193

11951194
<!-- plinss notes we may eventually want to choose other normalizations
@@ -1957,56 +1956,24 @@ <h3 id="the-default-pseudo">
19571956
like a selection of pizza toppings for example.
19581957

19591958
<h3 id="validity-pseudos">
1960-
The validity pseudo-classes: <code>:valid</code>, <code>:invalid</code>, and <code>:user-error</code></h3>
1959+
The validity pseudo-classes: <code>:valid</code> and <code>:invalid</code></h3>
19611960

19621961
<p>
19631962
An element is <dfn id="valid-pseudo">:valid</dfn>
19641963
or <dfn id="invalid-pseudo">:invalid</dfn>
19651964
when its contents or value is, respectively,
19661965
valid or invalid with respect to data validity semantics defined by the document language
19671966
(e.g. [[XFORMS10]] or [[HTML5]]).
1967+
An element which lacks data validity semantics is neither <code>:valid</code> nor <code>:invalid</code>.
19681968

1969-
<p>
1969+
<p class="note">
19701970
Note that there is a difference between an element which has no constraints,
19711971
and thus would always be <code>:valid</code>,
19721972
and one which has no data validity semantics at all,
19731973
and thus is neither <code>:valid</code> nor <code>:invalid</code>.
19741974
In HTML, for example, an <code>&lt;input type="text"></code> element may have no constraints,
19751975
but a <code>&lt;p></code> element has no validity semantics at all,
1976-
and so it never matches either of these pseudoclasses.
1977-
1978-
<p>
1979-
The <dfn id="user-error-pseudo">:user-error</dfn> pseudo-class
1980-
matches the same elements as <code>:invalid</code>,
1981-
but it only does so after the user has interacted with them.
1982-
The <code>:user-error</code> pseudo-class must match elements that are invalid
1983-
after the user attempts to submit the form containing them.
1984-
User-agents may allow it to match invalid elements earlier,
1985-
if they determine
1986-
(in a UA-specific manner)
1987-
that the user has "significantly interacted" with them.
1988-
1989-
<div class='example'>
1990-
<p>
1991-
For example, the input in the following document fragment
1992-
would match <code>:invalid</code> as soon as the page is loaded
1993-
(because it's empty, which violates the "required" constraint),
1994-
but it won't match <code>:user-error</code> until the user significantly interacts with the element,
1995-
or attempts to submit the form it's part of.
1996-
1997-
<pre><!--
1998-
-->&lt;form>&#xa;<!--
1999-
--> &lt;label>&#xa;<!--
2000-
--> First Name:&#xa;<!--
2001-
--> &lt;input name='first-name' required value=''>&#xa;<!--
2002-
--> &lt;/label>&#xa;<!--
2003-
--> ...&#xa;<!--
2004-
-->&lt;/form>&lt;/pre>
2005-
</div>
2006-
2007-
<p class="issue">
2008-
What parts of <a href="https://developer.mozilla.org/en-US/docs/CSS/:-moz-ui-invalid">:-moz-ui-invalid description</a> do we want to spec here?
2009-
Or put as examples?
1976+
and so it never matches either of these pseudo-classes.
20101977

20111978
<h3 id="range-pseudos">
20121979
The range pseudo-classes <code>:in-range</code> and <code>:out-of-range</code></h3>
@@ -2033,6 +2000,58 @@ <h3 id="opt-pseudos">
20332000
form it belongs to can be validly submitted. Elements that are not
20342001
form elements are neither required nor optional.
20352002

2003+
<h3 id="user-pseudos">
2004+
The user-interaction pseudo-class <code>:user-error</code></h3>
2005+
2006+
<p>
2007+
The <dfn id="user-error-pseudo">:user-error</dfn> pseudo-class
2008+
represents an input element with incorrect input, but only
2009+
<em>after</em> the user has significantly interacted with it.
2010+
The <code>:user-error</code> pseudo-class
2011+
must match an <code>:invalid</code>, <code>:out-of-range</code>, or empty-but-<code>:required</code> form element
2012+
between the time the user has attempted to submit the form
2013+
and before the user has interacted again with the form element.
2014+
User-agents may allow it to match such elements at other times,
2015+
as would be appropriate for highlighting an error to the user.
2016+
For example, a UA may choose to have <code>:user-error</code> match
2017+
an <code>:invalid</code> element once the user has typed some text into it
2018+
and changed the focus to another element,
2019+
and to stop matching only after the user has successfully corrected the input.
2020+
2021+
<div class='example'>
2022+
<p>
2023+
For example, the input in the following document fragment
2024+
would match <code>:invalid</code> as soon as the page is loaded
2025+
(because it the initial value violates the max-constraint),
2026+
but it won't match <code>:user-error</code> until the user significantly interacts with the element,
2027+
or attempts to submit the form it's part of.
2028+
2029+
<pre><!--
2030+
-->&lt;form>&#xa;<!--
2031+
--> &lt;label>&#xa;<!--
2032+
--> Volume:&#xa;<!--
2033+
--> &lt;input name='vol' type=number min=0 max=10 value=11>&#xa;<!--
2034+
--> &lt;/label>&#xa;<!--
2035+
--> ...&#xa;<!--
2036+
-->&lt;/form>&lt;/pre>
2037+
</div>
2038+
2039+
<!--
2040+
<p class="issue">
2041+
If it's necessary to distinguish between omitted and invalid values,
2042+
<code>:user-invalid</code> and <code>:user-omitted</code> could be used.
2043+
-->
2044+
2045+
<p class="issue">
2046+
What parts of <a href="https://developer.mozilla.org/en-US/docs/CSS/:-moz-ui-invalid">:-moz-ui-invalid description</a> do we want to spec here?
2047+
Or put as examples?
2048+
2049+
<p class="issue">
2050+
There was a suggestion to have a <code>:user-interacted</code> pseudo-class
2051+
instead of or in addition to this one.
2052+
It's unclear what the criteria would be for matching it, however.
2053+
In particular, it seems unlikely to be a replacement of this one if form validation of an untouched form control is not part of the criteria.
2054+
20362055
<h3 id="rw-pseudos">
20372056
The mutability pseudo-classes <code>:read-only</code> and <code>:read-write</code></h3>
20382057

0 commit comments

Comments
 (0)