Skip to content

Commit

Permalink
Add <form>'s "firing submission events" flag
Browse files Browse the repository at this point in the history
Fixes #4620. This flag prevents reentrancy into the submission algorithm
during submit or invalid events. Blink and Gecko implement this for
submit only; WebKit implements it for both. The specification chooses
WebKit's behavior.

Tests: web-platform-tests/wpt#16811
  • Loading branch information
tkent-google authored and domenic committed May 15, 2019
1 parent 7657985 commit cb55dca
Showing 1 changed file with 30 additions and 17 deletions.
47 changes: 30 additions & 17 deletions source
Original file line number Diff line number Diff line change
Expand Up @@ -56054,6 +56054,9 @@ fur
<p>Each <code>form</code> element has a <dfn>constructing entry list</dfn> boolean, initially
false.</p>

<p>Each <code>form</code> element has a <dfn>firing submission events</dfn> boolean, initially
false.</p>

<p>When a <code>form</code> element <var>form</var> is <dfn
data-x="concept-form-submit">submitted</dfn> from an element <var>submitter</var>
(typically a button), optionally with a <var>submitted from <code
Expand All @@ -56073,26 +56076,40 @@ fur
<li><p>Let <var>form browsing context</var> be the <span data-x="concept-document-bc">browsing
context</span> of <var>form document</var>.</p></li>

<!-- lock (all the following steps are skipped if called from submit() - see unlock step below) -->

<li><p>If the <var>submitted from <code data-x="dom-form-submit">submit()</code>
method</var> flag is not set, and the <var>submitter</var> element's <span
data-x="concept-fs-novalidate">no-validate state</span> is false, then <span>interactively
validate the constraints</span> of <var>form</var> and examine the result: if the result
is negative (the constraint validation concluded that there were invalid fields and probably
informed the user of this) then <span data-x="concept-event-fire">fire an event</span> named
<code data-x="event-invalid">invalid</code> at the <var>form</var> element and then return.</p></li>

<li>
<p>If the <var>submitted from <code data-x="dom-form-submit">submit()</code> method</var> flag
is not set, then:

<ol>
<li><p>If <var>form</var>'s <span>firing submission events</span> is true, then
return.</p></li>

<li><p>Set <var>form</var>'s <span>firing submission events</span> to true.</p></li>

<li>
<p>If the <var>submitter</var> element's <span data-x="concept-fs-novalidate">no-validate
state</span> is false, then <span>interactively validate the constraints</span> of
<var>form</var> and examine the result. If the result is negative (i.e., the constraint
validation concluded that there were invalid fields and probably informed the user of this),
then:</p>

<ol>
<li><p><span data-x="concept-event-fire">Fire an event</span> named <code
data-x="event-invalid">invalid</code> at the <var>form</var> element.</p></li>

<li><p>Set <var>form</var>'s <span>firing submission events</span> to false.</p></li>

<li><p>Return.</p></li>
</ol>
</li>

<li><p>Let <var>continue</var> be the result of <span data-x="concept-event-fire">firing an
event</span> named <code data-x="event-submit">submit</code> at <var>form</var>, with the
<code data-x="dom-Event-bubbles">bubbles</code> attribute initialized to true and the <code
event</span> named <code data-x="event-submit">submit</code> at <var>form</var>, with the <code
data-x="dom-Event-bubbles">bubbles</code> attribute initialized to true and the <code
data-x="dom-Event-cancelable">cancelable</code> attribute initialized to true.</p></li>

<li><p>Set <var>form</var>'s <span>firing submission events</span> to false.</p></li>

<li><p>If <var>continue</var> is false, then return.</p></li>

<li>
Expand All @@ -56102,11 +56119,7 @@ fur
data-x="event-submit">submit</code> event could have changed the outcome.</p>
</li>
</ol>

<!-- if you add any steps between the "lock" and "unlock" lines, make sure to update the step
immediately before the "lock" line -->

<!-- unlock -->
</li>

<li><p>Let <var>encoding</var> be the result of <span>picking an encoding for the
form</span>.</p>
Expand Down

0 comments on commit cb55dca

Please sign in to comment.