Closed
Bug 586329
Opened 14 years ago
Closed 4 years ago
HTMLFormElement.submit() stops working if a submit button removes itself from the form during its click event handler
Categories
(Core :: DOM: Forms, defect, P3)
Tracking
()
RESOLVED
FIXED
92 Branch
Tracking | Status | |
---|---|---|
firefox92 | --- | fixed |
People
(Reporter: julien.cheritat, Assigned: edgar)
References
Details
Attachments
(2 files)
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/533.4 (KHTML, like Gecko) Chrome/5.0.375.125 Safari/533.4
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; fr; rv:1.9.2.8) Gecko/20100722 Firefox/3.6.8
When an <input type=submit> element removes itself during its click event, the submit() method stops working on the parent form element.
Here is a small example to demonstrate this issue :
Reproducible: Always
Steps to Reproduce:
1.Create an HTML file with the content given below
2.Open this file in Firefox (same issue in K-meleon)
3.Click on the "remove" button
4.Click on the "JS submit" button
Actual Results:
Nothing happens
Expected Results:
The form should be submitted
Html file used to reproduce :
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><head><title></title>
<script>function c(){ document.forms[0].removeChild(document.getElementById("a3")); return false;}</script>
</head>
<body>
<form method="get" id="test" action="http://bugzilla.mozilla.org/">
<input type="button" value="JS submit" onclick="document.forms[0].submit()" name="a1"/>
<input type="submit" value="Form submit" name="a2" />
<input type="submit" value="removed" onclick="return c();" name="a3" id="a3"/>
</form>
</body>
</html>
Reporter | ||
Comment 1•14 years ago
|
||
![]() |
||
Comment 2•14 years ago
|
||
> The form should be submitted
Why?
Here's what the HTML5 spec has to say:
The element's activation behavior, if the element has a form owner, is to
submit the form owner from the input element; otherwise, it is to do nothing.
Activation behavior is the default action, so happens after user-defined event handlers have fired. Since the event handler removes the input from the form, the input no longer has a form owner at activation time, so nothing happens.
Which is exactly the behavior I see in Gecko, Webkit, and Presto.
Status: UNCONFIRMED → RESOLVED
Closed: 14 years ago
Resolution: --- → INVALID
Reporter | ||
Comment 3•14 years ago
|
||
The "JS submit" button has document.forms[0].submit(), clicking on it MUST submit the form.
Status: RESOLVED → UNCONFIRMED
Resolution: INVALID → ---
![]() |
||
Comment 4•14 years ago
|
||
Oh, I see. I thought you meant that clicking the "removed" button was supposed to submit it.
Confirming; presumably the issue is something to do with pending submissions not being cleared out when the third button is removed...
Status: UNCONFIRMED → NEW
Ever confirmed: true
Comment 5•11 years ago
|
||
This bug also affects modern platforms (tested Ubuntu Linux 13.10 and Windows 7, but it's probably platform-independent). Please update when you're able.
Description and solution to the problem:
https://groups.google.com/forum/#!topic/mozilla.support.firefox/OSfbE-z9B9I
Comment 7•9 years ago
|
||
Breaks google.co.jp's search page - if you select things in the autocomplete menu it doesn't submit. See https://webcompat.com/issues/1169
See Also: → https://webcompat.com/issues/1169
Comment 8•8 years ago
|
||
For anyone else looking at this, a workaround appears to be setting the button's type property to "button" - https://bugzilla.mozilla.org/show_bug.cgi?id=494755#c5
Updated•6 years ago
|
Component: HTML: Form Submission → DOM: Core & HTML
Assignee | ||
Updated•4 years ago
|
Severity: normal → S3
Component: DOM: Core & HTML → DOM: Forms
Priority: -- → P3
Assignee | ||
Comment 12•4 years ago
|
||
Updated•4 years ago
|
Assignee: nobody → echen
Attachment #9230271 -
Attachment description: WIP: Bug 586329 - Clear the defer submission state when submit button is removed from the form during its click event handler; r=smaug → Bug 586329 - Clear the defer submission state when submit button is removed from the form during its click event handler; r=smaug
Status: NEW → ASSIGNED
Assignee | ||
Comment 13•4 years ago
|
||
Assignee | ||
Comment 14•4 years ago
•
|
||
Assignee | ||
Comment 15•4 years ago
|
||
Comment 16•4 years ago
|
||
Pushed by echen@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/2ebb071ca4b4
Clear the defer submission state when submit button is removed from the form during its click event handler; r=smaug
Created web-platform-tests PR https://github.com/web-platform-tests/wpt/pull/29689 for changes under testing/web-platform/tests
Comment 18•4 years ago
|
||
bugherder |
Status: ASSIGNED → RESOLVED
Closed: 14 years ago → 4 years ago
status-firefox92:
--- → fixed
Resolution: --- → FIXED
Target Milestone: --- → 92 Branch
Upstream PR merged by moz-wptsync-bot
You need to log in
before you can comment on or make changes to this bug.
Description
•