Closed
Bug 317632
Opened 20 years ago
Closed 20 years ago
Setting innerHTML on a <select> populates select incorrectly
Categories
(Core :: DOM: HTML Parser, defect)
Tracking
()
RESOLVED
DUPLICATE
of bug 100175
People
(Reporter: aquarius, Assigned: mrbkap)
Details
(Keywords: testcase)
Attachments
(1 file)
581 bytes,
text/html
|
Details |
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-GB; rv:1.7.12) Gecko/20051010 Firefox/1.0.7 (Ubuntu package 1.0.7)
Build Identifier: Mozilla/5.0 (X11; U; Linux i686; en-GB; rv:1.7.12) Gecko/20051010 Firefox/1.0.7 (Ubuntu package 1.0.7)
If I set the innerHTML of a <select> element to a string containing <option>s, Firefox creates one option containing all the text, rather than multiple options.
Demonstration code:
<html>
<head>
<title>test inserting</title>
<script type="text/javascript">
function ins() {
var s = document.getElementById('sel');
var otxt = '<option value="1">one</option>\n<option value="2">two</option>\n';
s.innerHTML = otxt;
}
</script>
</head>
<body>
<select id="sel"></select>
<button onclick="ins()">click</button>
</body>
</html>
This should, when the button is clicked, add two options to the <select>, with text "one" and "two" respectively. Instead, it adds one option with text "onetwo", which is wrong.
Reproducible: Always
Steps to Reproduce:
1. Open a page containing above HTML.
2. Click the button.
3.
Actual Results:
One option is added to the dropdown, with text "onetwo".
Expected Results:
Two options should be added, one with text "one" and the second with text "two".
Comment 1•20 years ago
|
||
testcase. I cleaned up what the reporter gave so it would validate.
Comment 2•20 years ago
|
||
Works for me with trunk nightly Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9a1) Gecko/20051120 Firefox/1.6a1
I couldn't reproduce the reported behavior, but the testcase didn't work until I fixed up the html. The attached testcase works fine in the trunk.
Keywords: testcase
Comment 3•20 years ago
|
||
WFM on 1.5 RC3 [Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8) Gecko/20051111 Firefox/1.5 ID:2005111116] using the testcase in bug 100175 (which is exactly what the reporter is describing).
Assignee: nobody → mrbkap
Component: General → HTML: Parser
Product: Firefox → Core
QA Contact: general → parser
Version: unspecified → 1.7 Branch
Comment 4•20 years ago
|
||
This bug has been fixed in the trunk and 1.8 branches but just not in old 1.7 branch.
Reporter, you can download Firefox 1.5 RC3 from http://www.mozilla.org/projects/firefox/, which will include the fix to this bug.
*** This bug has been marked as a duplicate of 100175 ***
Status: UNCONFIRMED → RESOLVED
Closed: 20 years ago
Resolution: --- → DUPLICATE
You need to log in
before you can comment on or make changes to this bug.
Description
•