Closed Bug 377815 Opened 17 years ago Closed 17 years ago

radio button group's selected index changes on page reload when adding other inputs dynamically via JS

Categories

(Core :: DOM: Navigation, defect)

defect
Not set
normal

Tracking

()

RESOLVED DUPLICATE of bug 311507

People

(Reporter: mikea, Unassigned)

Details

Attachments

(2 files, 3 obsolete files)

User-Agent:       Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en-US; rv:1.9a4pre) Gecko/20070417 Minefield/3.0a4pre
Build Identifier: Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en-US; rv:1.9a4pre) Gecko/20070417 Minefield/3.0a4pre

This is not a duplicated of bug 46845.

After reloading a page in which INPUT elements have been dynamically added to the page above a group of radio buttons, the selected index of those radio buttons will shift depending on the number of dynamically added INPUT elements.

Reproducible: Always

Steps to Reproduce:
See attached test case.

OR

1. Create a page with one group of radio buttons, have the first radio button be selected by default (not necessary: included for clarity). 
2. Using .innerHTML, add one other INPUT element (text, hidden, button: doesn't matter) above the radio buttons during window.onload
3. Reload the page by clicking the reload button in Firefox's toolbar.
Actual Results:  
The selected index of the radio buttons increments by one on each page reload.

Expected Results:  
The radio button that was selected before reloading the page should stay selected after reloading the page.

If you dynamically add N > 1 INPUT element above the radio buttons, the selected index of the radio button will increment by N on each page reload.

Originally reported as bug in WordPress:
http://trac.wordpress.org/ticket/3895
(see http://trac.wordpress.org/ticket/3895#comment:26)

Example test case attached.

Also reproducible on:
Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; rv:1.8.1.3) Gecko/20070309 Firefox/2.0.0.3
Attached file HTML test case (obsolete) —
Attachment #261876 - Attachment mime type: text/html → text/plain
Attachment #261876 - Attachment mime type: text/plain → text/html
Attachment #261876 - Attachment mime type: text/html → text/plain
Also reproducible on:
Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en-US; rv:1.8.0.11) Gecko/20070312 Firefox/1.5.0.11
Attachment #261876 - Attachment mime type: text/plain → application/xhtml+xml
My first bug report.

The attached test case does not work if previewed here on this site because javascript is really sloppy.  It will work if you download source and try it out locally.
Component: General → History: Session
Product: Firefox → Core
QA Contact: general → history.session
Version: unspecified → Trunk
OS: Mac OS X → All
Hardware: Macintosh → All
Attached file testcase (obsolete) —
Thanks for the bug report, Mike. This is a testcase that should work online.
This indeed seems like a valid bug, but first I'm trying to find out if this isn't a duplicate of some other bug.
Attached file testcase (obsolete) —
Grr, this one should work online.
Attachment #261887 - Attachment is obsolete: true
Attachment #261888 - Attachment is obsolete: true
Ok, there is at least one bug that was filed earlier and is also about this issue, so I'm marking this a duplicate of that bug (but still thanks for filing the bug!).
Status: UNCONFIRMED → RESOLVED
Closed: 17 years ago
Resolution: --- → DUPLICATE
Argh, sorry, not a duplicate, the testcase in that bug reacts differently in current trunk build. But still, this bug is probably related to that bug.
Status: RESOLVED → UNCONFIRMED
Depends on: 372887
Resolution: DUPLICATE → ---
Thanks for cleaning up the testcase, Martijn.  Bug 372887 looks remarkably similar; I agree they must be related.

If you want to see the N > 1 case, I've got an attachment I'm about to upload that might work.  If it doesn't work, I'm giving up on the testcases.  Yours works perfectly on its own.

Attachment #261876 - Attachment is obsolete: true
Sorry, I just found a bug that really is the same.
Status: UNCONFIRMED → RESOLVED
Closed: 17 years ago17 years ago
No longer depends on: 372887
Resolution: --- → DUPLICATE
Component: History: Session → Document Navigation
QA Contact: history.session → docshell
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: