Skip to content

Commit 864288a

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

File tree

1 file changed

+75
-31
lines changed

1 file changed

+75
-31
lines changed

source

Lines changed: 75 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
@@ -52827,6 +52829,8 @@ interface <dfn interface>HTMLSelectElement</dfn> : <span>HTMLElement</span> {
5282752829
element to run these steps:</p>
5282852830

5282952831
<ol>
52832+
<li>Set the <code>select</code> element's <span>user interacted</span> to true.</li>
52833+
5283052834
<li><p><span data-x="concept-event-fire">Fire an event</span> named <code
5283152835
data-x="event-input">input</code> at the <code>select</code> element, with the <code
5283252836
data-x="dom-Event-bubbles">bubbles</code> and <code data-x="dom-Event-composed">composed</code>
@@ -52843,7 +52847,8 @@ interface <dfn interface>HTMLSelectElement</dfn> : <span>HTMLElement</span> {
5284352847
data-x="concept-option-selectedness">selectedness</span> to true if the <code>option</code>
5284452848
element has a <code data-x="attr-option-selected">selected</code> attribute, and false otherwise,
5284552849
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>
52850+
<code>option</code> elements <span>ask for a reset</span>. The element should also set the
52851+
<span>user interacted</span> to false.</p>
5284752852

5284852853
</div>
5284952854

@@ -53779,9 +53784,9 @@ interface <dfn interface>HTMLTextAreaElement</dfn> : <span>HTMLElement</span> {
5377953784
content</span>.</p>
5378053785

5378153786
<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>
53787+
elements is to set the user interacted, <span data-x="concept-fe-dirty">dirty value flag</span>
53788+
back to false, and set the <span data-x="concept-textarea-raw-value">raw value</span> of element
53789+
to its <span>child text content</span>.</p>
5378553790

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

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

5886558873
<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>
58874+
<var>form</var>, <var>submitter</var>, <var>encoding</var> and <var>true</var>.</p></li>
5886758875

5886858876
<li><p><span>Assert</span>: <var>entry list</var> is not null.</p></li>
5886958877

@@ -59239,8 +59247,8 @@ fur
5923959247

5924059248
<p>The algorithm to <dfn id="constructing-the-form-data-set" export data-lt="constructing the
5924159249
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>
59250+
<var>form</var>, an optional <var>submitter</var>, an optional <var>setUserInteracted</var>
59251+
and an optional <var>encoding</var>, is as follows. If not specified otherwise, <var>submitter</var> is null.</p>
5924459252

5924559253
<ol>
5924659254
<li><p>If <var>form</var>'s <span>constructing entry list</span> is true, then return
@@ -59257,6 +59265,8 @@ fur
5925759265
<p>For each element <var>field</var> in <var>controls</var>, in <span>tree order</span>:</p>
5925859266

5925959267
<ol>
59268+
<li>If <var>setUserInteracted</var> is true, set <var>field</var>'s <span>user interacted</span> to true.</li>
59269+
5926059270
<li>
5926159271
<p>If any of the following is true:</p>
5926259272

@@ -73089,6 +73099,32 @@ Demos:
7308973099
</ul>
7309073100
</dd>
7309173101

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

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

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

0 commit comments

Comments
 (0)