Skip to content

Commit

Permalink
Introduce SubmitEvent for the form 'submit' event
Browse files Browse the repository at this point in the history
It has a submitter attribute, so this fixes #3195.

As part of this, update requestSubmit() to accept null, so that
requestSubmit(e.submitter) always works. (e.submitter is null for
implicit submission, per the discussion in
#3195 (comment).)

Tests: web-platform-tests/wpt#19562
  • Loading branch information
tkent-google authored and domenic committed Oct 31, 2019
1 parent f101f1e commit f476180
Showing 1 changed file with 36 additions and 4 deletions.
40 changes: 36 additions & 4 deletions source
Original file line number Diff line number Diff line change
Expand Up @@ -43226,7 +43226,7 @@ interface <dfn>HTMLFormElement</dfn> : <span>HTMLElement</span> {
<a href="#dom-form-nameditem">getter</a> (<span>RadioNodeList</span> or <span>Element</span>) (DOMString name);

void <span data-x="dom-form-submit">submit</span>();
void <span data-x="dom-form-requestSubmit">requestSubmit</span>(optional <span>HTMLElement</span> submitter);
void <span data-x="dom-form-requestSubmit">requestSubmit</span>(optional <span>HTMLElement</span>? submitter = null);
[<span>CEReactions</span>] void <span data-x="dom-form-reset">reset</span>();
boolean <span data-x="dom-form-checkValidity">checkValidity</span>();
boolean <span data-x="dom-form-reportValidity">reportValidity</span>();
Expand Down Expand Up @@ -43596,7 +43596,7 @@ interface <dfn>HTMLFormElement</dfn> : <span>HTMLElement</span> {

<ol>
<li>
<p>If <var>submitter</var> was given, then:</p>
<p>If <var>submitter</var> is not null, then:</p>

<ol>
<li><p>If <var>submitter</var> is not a <span data-x="concept-submit-button">submit
Expand Down Expand Up @@ -56321,9 +56321,14 @@ fur
</ol>
</li>

<li><p>Let <var>submitterButton</var> be null if <var>submitter</var> is <var>form</var>.
Otherwise, let <var>submitterButton</var> be <var>submitter</var>.</p></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> using
<code>SubmitEvent</code>, with the <code data-x="dom-SubmitEvent-submitter">submitter</code>
attribute initialized to <var>submitterButton</var>, 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>
Expand Down Expand Up @@ -57083,6 +57088,33 @@ fur
not reliably interpretable by computer, as the format is ambiguous (for example, there is no way
to distinguish a literal newline in a value from the newline at the end of the value).</p>

<h5>The <code>SubmitEvent</code> interface</h5>

<pre><code class="idl" data-x="">[Exposed=Window]
interface <dfn>SubmitEvent</dfn> : <span>Event</span> {
constructor(DOMString type, optional <span>SubmitEventInit</span> eventInitDict = {});

readonly attribute <span>HTMLElement</span>? <span data-x="dom-SubmitEvent-submitter">submitter</span>;
};

dictionary <dfn>SubmitEventInit</dfn> : <span>EventInit</span> {
<span>HTMLElement</span>? submitter = null;
};</code></pre>

<dl class="domintro">
<dt><var>event</var> . <code data-x="dom-SubmitEvent-submitter">submitter</code></dt>
<dd><p>Returns the element representing the <span data-x="concept-submit-button">submit
button</span> that triggered the <span>form submission</span>, or null if the submission was
not triggered by a button.</p></dd>
</dl>

<div w-nodev>

<p>The <dfn><code data-x="dom-SubmitEvent-submitter">submitter</code></dfn> attribute must return
the value it was initialized to.</p>

</div>

<h5>The <code>FormDataEvent</code> interface</h5>

<pre><code class="idl" data-x="">[Exposed=Window,
Expand Down

0 comments on commit f476180

Please sign in to comment.