-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes #3117.
- Loading branch information
Showing
5 changed files
with
72 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
"use strict"; | ||
|
||
const EventImpl = require("./Event-impl").implementation; | ||
|
||
const SubmitEventInit = require("../generated/SubmitEventInit"); | ||
|
||
// https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#the-submitevent-interface | ||
class SubmitEventImpl extends EventImpl {} | ||
SubmitEventImpl.defaultInit = SubmitEventInit.convert(undefined, undefined); | ||
|
||
module.exports = { | ||
implementation: SubmitEventImpl | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#the-submitevent-interface | ||
[Exposed=Window] | ||
interface SubmitEvent : Event { | ||
constructor(DOMString type, optional SubmitEventInit eventInitDict = {}); | ||
|
||
readonly attribute HTMLElement? submitter; | ||
}; | ||
|
||
dictionary SubmitEventInit : EventInit { | ||
HTMLElement? submitter = null; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
test/web-platform-tests/to-upstream/html/semantics/forms/form-submission-0/submit-event.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<!DOCTYPE html> | ||
<meta charset="utf-8"> | ||
<title>HTML Test: form submit event</title> | ||
<link rel="help" href="https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#form-submission-algorithm"> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
|
||
<body> | ||
<script> | ||
"use strict"; | ||
|
||
let submitEvent; | ||
function prepareForm() { | ||
submitEvent = undefined; | ||
const form = document.createElement("FORM"); | ||
const submitButton = document.createElement("BUTTON"); | ||
form.appendChild(submitButton); | ||
form.addEventListener("submit", event => { | ||
event.preventDefault(); | ||
submitEvent = event; | ||
}); | ||
document.body.appendChild(form); | ||
return { form, submitButton }; | ||
} | ||
|
||
test(() => { | ||
const { submitButton } = prepareForm(); | ||
submitButton.click(); | ||
assert_equals(submitEvent.submitter, submitButton, "Submitter is set"); | ||
}, "Clicking a submit button sets the submitter"); | ||
|
||
test(() => { | ||
const { form, submitButton } = prepareForm(); | ||
form.requestSubmit(submitButton); | ||
assert_equals(submitEvent.submitter, submitButton, "Submitter is set"); | ||
}, "Requesting submit with a submitter sets the submitter"); | ||
|
||
test(() => { | ||
const { form } = prepareForm(); | ||
form.requestSubmit(); | ||
assert_equals(submitEvent.submitter, null, "Submitter is not set"); | ||
}, "Requesting submit without a submitter does not set the submitter"); | ||
</script> |