Bug 265077
| Summary: | Submitting a form with requestSubmit() sets the submitter of the SubmitEvent object to the most recent submitter instead of the one passed, or nothing if no argument is given | ||
|---|---|---|---|
| Product: | WebKit | Reporter: | Caleb Land <caleb> |
| Component: | Forms | Assignee: | Nobody <webkit-unassigned> |
| Status: | RESOLVED INVALID | ||
| Severity: | Normal | CC: | caleb, cdumez, wenson_hsieh |
| Priority: | P2 | ||
| Version: | Safari 17 | ||
| Hardware: | Mac (Apple Silicon) | ||
| OS: | macOS 14 | ||
Caleb Land
Submitting a form with requestSubmit() (with or without a submitter argument) sets the "submitter" property of the SubmitEvent to the most recently used submitter.
Using the form and javascript below you can see that first clicking one of the buttons that submits via "requestSubmit" shows that the "submitter" property of the SubmitEvent is undefined.
However, if you first click one of the real submit buttons and then click one of the requestSubmit buttons, the most recently clicked real submit button is put in the submitter property.
<form id="form" action="/" method="post">
<button type="submit" name="submit-button" value="submit-button">Submit Button #1</button>
<button type="submit" name="other-submit" value="other-submit">Other Submit Button</button>
<button type="button" id="via-other">Submit via requestSubmit(otherSubmitButton)</button>
<button type="button" id="via-none">Submit via requestSubmit()</button>
</form>
<script type="application/javascript">
document.forms[0].addEventListener("submit", function(event) {
event.preventDefault()
console.log(event.submitter)
})
document.querySelector("#via-other").addEventListener("click", function(event) {
event.preventDefault()
let otherSubmitButton = document.querySelector("[name='other-submit']")
document.forms[0].requestSubmit(otherSubmitButton)
})
document.querySelector("#via-none").addEventListener("click", function(event) {
event.preventDefault()
document.forms[0].requestSubmit()
})
</script>
I would expect requestSubmit() to set the submitter to undefined and the requestSubmit(someOtherSubmit) to always have someOtherButton as the submitter, and this is how Chrome and Firefox behave.
| Attachments | ||
|---|---|---|
| Add attachment proposed patch, testcase, etc. |