Closed Bug 100175 Opened 23 years ago Closed 20 years ago

innerHTML smushing multiple options together on select

Categories

(Core :: DOM: HTML Parser, defect, P3)

x86
Linux
defect

Tracking

()

RESOLVED FIXED
Future

People

(Reporter: john, Assigned: mrbkap)

References

()

Details

Attachments

(1 file, 1 obsolete file)

When you set innerHTML = "<option>...<option>..." it smushes the options together into one big option and adds that to <select>. This is consistent and reproducible on 0.9.4 and beyond (haven't tried earlier). Relevant JavaScript:sel.innerHTML = "<OPTION VALUE='A'>A</OPTION><OPTION VALUE='B'>B</OPTION>"; Removing </OPTION> doesn't fix the problem. It would appear that this is a bug in innerHTML or in adding HTML to a tree rather than <select> itself; adding individual options, it should be noted, works fine: http://www.johnkeiser.com/mozilla/select/jsadd.html.
jkeiser, I can't access the testcase in this bug, is it still available somewhere? Is this problem still around?
Oops, it's moved to a bigger regression test page. Setting URL. Click "innerHTML =" button on one of the selects. It's still acting the same for me nowm showing "new0new1" for example, the first time you click. Note that the smushed-up option can't be selected either. That might actually be a clue.
The parser doesn't get this right, it ends up adding one single textnode in stead of adding two options to the select when innerHTML is set to <option>...</option><option>...</option>. Over to the parser component.
Assignee: jst → harishd
Component: DOM Mozilla Extensions → Parser
QA Contact: lchiang → moied
Harish, does this look reasonable or is there a better way to do this?
jst: It should be possible to tweak the element table instead. I just don't like the idea of calling OpenContainer() abruptly :)
Status: NEW → ASSIGNED
Priority: -- → P3
Target Milestone: --- → mozilla0.9.9
mass move to 1.1
Target Milestone: mozilla0.9.9 → mozilla1.1
[was 1.1alpha]
Target Milestone: mozilla1.1alpha → Future
Allowing <endnote> anywhere fixes this bug, but I'm not entirely sure what <endnote> is at the moment. I'll attach a patch once my tree is clear from bug 88952.
This is basically the same thing as jst's patch, except it uses the elementtable. For the record, this is one of those times when working on this code is fun (when you make a small change to a property and the algorithms just handle it).
Assignee: harishd → mrbkap
Attachment #61861 - Attachment is obsolete: true
Comment on attachment 166726 [details] [diff] [review] whack the parser in a friendlier way jst, this is basically your patch, just using the element table to describe what we want to happen with endnote.
Attachment #166726 - Flags: superreview?(jst)
Attachment #166726 - Flags: review?(jst)
Comment on attachment 166726 [details] [diff] [review] whack the parser in a friendlier way Add a comment for why this is needed, and r+sr=bzbarsky
Attachment #166726 - Flags: superreview?(jst)
Attachment #166726 - Flags: superreview+
Attachment #166726 - Flags: review?(jst)
Attachment #166726 - Flags: review+
Fix checked in: Checking in src/nsElementTable.cpp; /cvsroot/mozilla/parser/htmlparser/src/nsElementTable.cpp,v <-- nsElementTable .cpp new revision: 3.163; previous revision: 3.162 done
Status: ASSIGNED → RESOLVED
Closed: 20 years ago
Resolution: --- → FIXED
*** Bug 317632 has been marked as a duplicate of this bug. ***
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: