Skip to content

Commit 030429b

Browse files
committed
Spec :user-invalid & :user-valid
Fixes whatwg#8452
1 parent c97651a commit 030429b

File tree

1 file changed

+73
-31
lines changed

1 file changed

+73
-31
lines changed

source

Lines changed: 73 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -47331,15 +47331,16 @@ interface <dfn interface>HTMLInputElement</dfn> : <span>HTMLElement</span> {
4733147331
<div w-nodev>
4733247332

4733347333
<p>The <span data-x="concept-form-reset-control">reset algorithm</span> for <code>input</code>
47334-
elements is to set the <span data-x="concept-fe-dirty">dirty value flag</span> and <span
47335-
data-x="concept-input-checked-dirty-flag">dirty checkedness flag</span> back to false, set the
47336-
<span data-x="concept-fe-value">value</span> of the element to the value of the <code
47337-
data-x="attr-input-value">value</code> content attribute, if there is one, or the empty string
47338-
otherwise, set the <span data-x="concept-fe-checked">checkedness</span> of the element to true if
47339-
the element has a <code data-x="attr-input-checked">checked</code> content attribute and false if
47340-
it does not, empty the list of <span data-x="concept-input-type-file-selected">selected
47341-
files</span>, and then invoke the <span>value sanitization algorithm</span>, if the <code
47342-
data-x="attr-input-type">type</code> attribute's current state defines one.</p>
47334+
elements is to set the <span>user interacted</span>, <span data-x="concept-fe-dirty">dirty value
47335+
flag</span> and <span data-x="concept-input-checked-dirty-flag">dirty checkedness flag</span>
47336+
back to false, set the <span data-x="concept-fe-value">value</span> of the element to the value
47337+
of the <code data-x="attr-input-value">value</code> content attribute, if there is one, or the
47338+
empty string otherwise, set the <span data-x="concept-fe-checked">checkedness</span> of the
47339+
element to true if the element has a <code data-x="attr-input-checked">checked</code> content
47340+
attribute and false if it does not, empty the list of <span
47341+
data-x="concept-input-type-file-selected">selected files</span>, and then invoke the <span>value
47342+
sanitization algorithm</span>, if the <code data-x="attr-input-type">type</code> attribute's
47343+
current state defines one.</p>
4734347344

4734447345
<p>Each <code>input</code> element can be <i data-x="concept-fe-mutable">mutable</i>. Except where
4734547346
otherwise specified, an <code>input</code> element is always <i
@@ -52260,17 +52261,18 @@ You cannot submit this form when the field is incorrect.</samp></pre>
5226052261

5226152262
<p>For <code>input</code> elements without a defined <span>input activation behavior</span>, but
5226252263
to which these events <span data-x="concept-input-apply">apply</span>, and for which the user
52263-
interface involves both interactive manipulation and an explicit commit action, then when the user
52264-
changes the element's <span data-x="concept-fe-value">value</span>, the user agent must
52264+
interface involves both interactive manipulation and an explicit commit action, then when the
52265+
user changes the element's <span data-x="concept-fe-value">value</span>, the user agent must
5226552266
<span>queue an element task</span> on the <span>user interaction task source</span> given the
5226652267
<code>input</code> element to <span data-x="concept-event-fire">fire an event</span> named <code
5226752268
data-x="event-input">input</code> at the <code>input</code> element, with the <code
5226852269
data-x="dom-Event-bubbles">bubbles</code> and <code data-x="dom-Event-composed">composed</code>
5226952270
attributes initialized to true, and any time the user commits the change, the user agent must
5227052271
<span>queue an element task</span> on the <span>user interaction task source</span> given the
52271-
<code>input</code> element to <span data-x="concept-event-fire">fire an event</span> named <code
52272-
data-x="event-change">change</code> at the <code>input</code> element, with the <code
52273-
data-x="dom-Event-bubbles">bubbles</code> attribute initialized to true.</p>
52272+
<code>input</code> element to set its <span>user interacted</span> to true and <span
52273+
data-x="concept-event-fire">fire an event</span> named <code data-x="event-change">change</code>
52274+
at the <code>input</code> element, with the <code data-x="dom-Event-bubbles">bubbles</code>
52275+
attribute initialized to true.</p>
5227452276

5227552277
<p class="example">An example of a user interface involving both interactive manipulation and a
5227652278
commit action would be a <span data-x="attr-input-type-range">Range</span> controls that use a
@@ -52843,7 +52845,8 @@ interface <dfn interface>HTMLSelectElement</dfn> : <span>HTMLElement</span> {
5284352845
data-x="concept-option-selectedness">selectedness</span> to true if the <code>option</code>
5284452846
element has a <code data-x="attr-option-selected">selected</code> attribute, and false otherwise,
5284552847
set their <span data-x="concept-option-dirtiness">dirtiness</span> to false, and then have the
52846-
<code>option</code> elements <span>ask for a reset</span>.</p>
52848+
<code>option</code> elements <span>ask for a reset</span>. The element should also set the
52849+
<span>user interacted</span> to false.</p>
5284752850

5284852851
</div>
5284952852

@@ -53779,9 +53782,9 @@ interface <dfn interface>HTMLTextAreaElement</dfn> : <span>HTMLElement</span> {
5377953782
content</span>.</p>
5378053783

5378153784
<p>The <span data-x="concept-form-reset-control">reset algorithm</span> for <code>textarea</code>
53782-
elements is to set the <span data-x="concept-fe-dirty">dirty value flag</span> back to false, and
53783-
set the <span data-x="concept-textarea-raw-value">raw value</span> of element to its <span>child
53784-
text content</span>.</p>
53785+
elements is to set the user interacted, <span data-x="concept-fe-dirty">dirty value flag</span>
53786+
back to false, and set the <span data-x="concept-textarea-raw-value">raw value</span> of element
53787+
to its <span>child text content</span>.</p>
5378553788

5378653789
<p>When a <code>textarea</code> element is popped off the <span>stack of open elements</span> of
5378753790
an <span>HTML parser</span> or <span>XML parser</span>, then the user agent must invoke the
@@ -55169,6 +55172,9 @@ interface <dfn interface>HTMLLegendElement</dfn> : <span>HTMLElement</span> {
5516955172
default value. If it is false, <span data-x="concept-fe-value">value</span> mirrors the default
5517055173
value. If it is true, the default value is ignored.</p>
5517155174

55175+
<p><code>input</code>, <code>textarea</code> and <code>select</code> elements have an
55176+
<dfn>user interacted</dfn> (a boolean). It is initially set to false.</p>
55177+
5517255178
<p>To define the behavior of constraint validation in the face of the <code>input</code>
5517355179
element's <code data-x="attr-input-multiple">multiple</code> attribute, <code>input</code> elements
5517455180
can also have separately defined <dfn data-x="concept-fe-values">value<em>s</em></dfn>.</p>
@@ -58863,7 +58869,7 @@ fur
5886358869
form</span>.</p>
5886458870

5886558871
<li><p>Let <var>entry list</var> be the result of <span>constructing the entry list</span> with
58866-
<var>form</var>, <var>submitter</var>, and <var>encoding</var>.</p></li>
58872+
<var>form</var>, <var>submitter</var>, <var>encoding</var> and <var>true</var>.</p></li>
5886758873

5886858874
<li><p><span>Assert</span>: <var>entry list</var> is not null.</p></li>
5886958875

@@ -59239,8 +59245,8 @@ fur
5923959245

5924059246
<p>The algorithm to <dfn id="constructing-the-form-data-set" export data-lt="constructing the
5924159247
entry list" data-x="constructing the entry list">construct the entry list</dfn> given a
59242-
<var>form</var>, an optional <var>submitter</var>, and an optional <var>encoding</var>, is as
59243-
follows. If not specified otherwise, <var>submitter</var> is null.</p>
59248+
<var>form</var>, an optional <var>submitter</var>, an optional <var>setUserInteracted</var>
59249+
and an optional <var>encoding</var>, is as follows. If not specified otherwise, <var>submitter</var> is null.</p>
5924459250

5924559251
<ol>
5924659252
<li><p>If <var>form</var>'s <span>constructing entry list</span> is true, then return
@@ -59257,6 +59263,8 @@ fur
5925759263
<p>For each element <var>field</var> in <var>controls</var>, in <span>tree order</span>:</p>
5925859264

5925959265
<ol>
59266+
<li>If <var>setUserInteracted</var> is true, set <var>field</var>'s <span>user interacted</span> to true.</li>
59267+
5926059268
<li>
5926159269
<p>If any of the following is true:</p>
5926259270

@@ -73089,6 +73097,32 @@ Demos:
7308973097
</ul>
7309073098
</dd>
7309173099

73100+
<dt><dfn selector noexport><code data-x="selector-user-valid">:user-valid</code></dfn></dt>
73101+
<dd>
73102+
<p>The <code data-x="selector-user-valid">:user-valid</code> <span>pseudo-class</span> must match
73103+
any element falling into one of the following categories:</p>
73104+
<ul>
73105+
<li><code>input</code> and <code>textarea</code> elements that have their <span>user interacted</span>
73106+
set to true, are <span data-x="candidate for constraint validation">candidates for constraint validation</span>
73107+
and that <span data-x="concept-fv-valid">satisfy their constraints</span>.</li>
73108+
<li><span data-x="concept-button">Buttons</span> and other built-in elements that are <span data-x="candidate for constraint validation">candidates
73109+
for constraint validation</span> and that <span data-x="concept-fv-valid">satisfy their constraints</span>.</li>
73110+
</ul>
73111+
</dd>
73112+
73113+
<dt><dfn selector noexport><code data-x="selector-user-invalid">:user-invalid</code></dfn></dt>
73114+
<dd>
73115+
<p>The <code data-x="selector-user-invalid">:user-invalid</code> <span>pseudo-class</span> must match
73116+
any element falling into one of the following categories:</p>
73117+
<ul>
73118+
<li><code>input</code> and <code>textarea</code> elements that have their <span>user interacted</span>
73119+
set to true, are <span data-x="candidate for constraint validation">candidates for constraint validation</span>
73120+
but do not <span data-x="concept-fv-valid">satisfy their constraints</span>.</li>
73121+
<li><span data-x="concept-button">Buttons</span> and other built-in elements that are <span data-x="candidate for constraint validation">candidates
73122+
for constraint validation</span> but do not <span data-x="concept-fv-valid">satisfy their constraints</span>.</li>
73123+
</ul>
73124+
</dd>
73125+
7309273126
<dt><dfn selector noexport><code data-x="selector-in-range">:in-range</code></dfn></dt>
7309373127
<dd>
7309473128
<p>The <code data-x="selector-in-range">:in-range</code> <span>pseudo-class</span> must match
@@ -78542,16 +78576,24 @@ partial interface <span id="NavigatorUserActivation-partial">Navigator</span> {
7854278576
these substeps:</p>
7854378577

7854478578
<ol>
78545-
<li id="unfocus-causes-change-event"><p>If <var>entry</var> is an <code>input</code>
78546-
element, and the <code data-x="event-change">change</code> event <span
78547-
data-x="concept-input-apply">applies</span> to the element, and the element does not have a
78548-
defined <span>activation behavior</span>, and the user has changed the element's <span
78549-
data-x="concept-fe-value">value</span> or its list of <span
78550-
data-x="concept-input-type-file-selected">selected files</span> while the control was focused
78551-
without committing that change (such that it is different to what it was when the control was
78552-
first focused), then <span data-x="concept-event-fire">fire an event</span> named <code
78553-
data-x="event-change">change</code> at the element, with the <code
78554-
data-x="dom-Event-bubbles">bubbles</code> attribute initialized to true.</p>
78579+
<li>
78580+
<p>If <var>entry</var> is an <code>input</code>
78581+
element, and the <code data-x="event-change">change</code> event <span
78582+
data-x="concept-input-apply">applies</span> to the element, and the element does not have a
78583+
defined <span>activation behavior</span>, and the user has changed the element's <span
78584+
data-x="concept-fe-value">value</span> or its list of <span
78585+
data-x="concept-input-type-file-selected">selected files</span> while the control was focused
78586+
without committing that change (such that it is different to what it was when the control was
78587+
first focused), then:
78588+
78589+
<ol>
78590+
<li>Set <var>entry</var>'s <span>user interacted</span> to true.</li>
78591+
78592+
<li id="unfocus-causes-change-event"><span data-x="concept-event-fire">Fire an event</span> named <code
78593+
data-x="event-change">change</code> at the element, with the <code
78594+
data-x="dom-Event-bubbles">bubbles</code> attribute initialized to true.</li>
78595+
</ol>
78596+
</li>
7855578597

7855678598
<li>
7855778599
<p>If <var>entry</var> is an element, let <var>blur event target</var> be

0 commit comments

Comments
 (0)