JavaScript submit() stops working after removing an element from the page using JavaScript

UNCONFIRMED
Unassigned

Status

()

Core
HTML: Form Submission
UNCONFIRMED
9 years ago
3 months ago

People

(Reporter: Pekka Laiho, Unassigned)

Tracking

1.9.1 Branch
x86
Windows XP
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment)

(Reporter)

Description

9 years ago
User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.2; en-US; rv:1.9.0.10) Gecko/2009042316 Firefox/3.0.10 (.NET CLR 3.5.30729)
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.2; en-US; rv:1.9.0.10) Gecko/2009042316 Firefox/3.0.10 (.NET CLR 3.5.30729)

I have 2 javascript functions: one that calls form.submit() and one that dynamically removes one row from a table (a TR element). After removing the row, the submit() function stops working.

This was tested in FireFox 3.0.10 and 3.5b4 and seems to be broken in both. However it seems to work ok in IE6 and Google Chrome.

// submit-function:
document.getElementById("budjetti_form").submit();

// remove tr-function:
var table = document.getElementById("budjetti_table");
var row = document.getElementById(id);
table.tBodies[0].removeChild(row);

Reproducible: Always

Steps to Reproduce:
Stated in the details-section.
Actual Results:  
Submit() function stops working.

Expected Results:  
Submit() should work normally after removing an element from the page.
Component: General → HTML: Form Submission
Product: Firefox → Core
QA Contact: general → form-submission
Version: unspecified → 1.9.1 Branch
Could be related to bug 586329, but this needs a testcase to be sure.

Comment 2

3 years ago
Description and solution to the problem:
https://groups.google.com/forum/#!topic/mozilla.support.firefox/OSfbE-z9B9I

Comment 3

2 years ago
Created attachment 8688747 [details]
test-case-2015-11-17.html

Attaching a test case demonstrating the issue (test-case-2015-11-17.html).

Steps to reproduce:

1. Open test-case-2015-11-17.html.
2. Press “Save”. Observe form is submitted.
3. Re-open test-case-2015-11-17.html.
4. Press “Remove” to remove the button and its containing <div>.
5. Press “Save”. Observe form does not submit.

Occurs on:

- Firefox 42.0 on Mac OS X 10.10.5.
- Firefox 42.0 / Windows 7.

Does not occur on:

- Safari 9.0.1 / Mac OS X 10.10.5.
- Opera 33.0 / Mac OS X 10.10.5.
- Chrome 46.0.2490.86 / Mac OS X 10.10.5.

Additional:

- Issue does not occur when `removeIt` is called from an event handler attribute. Issue does occur when `removeIt` is called from an event listener.
- Removing the call to `evt.target.parentNode.remove()` resolves the issue.

Comment 4

2 years ago
One other note on test-case-2015-11-17.html: changing the <button>’s type attribute to “button” also resolves/works around the issue.

Comment 5

a year ago
Thanks for the workaround Evan. I can confirm it with Firefox v53 - https://gist.github.com/robertknight/5f3832ba3300a6b6536a237382f1db81

Comment 6

7 months ago
can this bugs be solved or just we can closed it as incomplete?
You need to log in before you can comment on or make changes to this bug.