Closed Bug 182346 Opened 23 years ago Closed 19 years ago

{ib}Inconsistent innerHTML behaviour

Categories

(Core :: Layout: Block and Inline, defect)

x86
All
defect
Not set
normal

Tracking

()

RESOLVED WORKSFORME

People

(Reporter: Rob.Jones, Unassigned)

Details

Attachments

(2 files, 1 obsolete file)

User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.2b) Gecko/20021016 Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.2b) Gecko/20021016 These two functions cause different behaviour function addRow() { var rowObj = document.getElementById("HERE"); rowObj.innerHTML = ""; rowObj.innerHTML += "<div>Label</div>"; rowObj.innerHTML += "<span id='HERE'></span>"; } function addRow2() { var rowObj = document.getElementById("HERE"); rowObj.innerHTML = ""; rowObj.innerHTML += "<div>Label</div><span id='HERE'></span>"; } But to my mind they are logically the same. All I have done in the second function is write the two line '+=' into one line. I attach a test case. Reproducible: Always Steps to Reproduce: 1. 2. 3.
Attached file testcase (obsolete) —
Mass-reassigning bugs to dom_bugs@netscape.com
Assignee: jst → dom_bugs
I dont get this, in your testcase you have an element named "HERE", then when clicking on the addrow button you add yet another element inside that one with the same name. This is incorrect, an ID should be unique in the document.
The same bug occurs if you add a 0 to the spans id and use a var to increment the zero after each consecutive span that is added the bug will be slightly different in behaviour though, in that the bug reverses attaching new testcase in a bit verified bug on linux with mozilla 1.4
Status: UNCONFIRMED → NEW
Ever confirmed: true
OS: Windows 2000 → All
with this testcase, I get this behaviour: clicking only addrow2 has the desired effect clicking addrow1 the first time has the desired effect clicking addrow1 the second, third, fourth, etc time adds two lines. clicking addrow1, then addrow2, then addrow1 again will add *four* lines with the last addrow1, unless these are done with a blank span, then the last addrow1 won't add anything.
Attachment #107641 - Attachment is obsolete: true
This is the testcase for a part of this bug. It demonstrates that the problem is that we are appending spans in divs. If we append divs in divs, the probmem goes away. However this testcase does not deal with the fact that the other way of doing it (assigning to innerHTML in one line) works. That's for a later testcase. I'm guessing, based on this testcase that it should go to layout people.
I forgot to mention that it's not a DOM problem because the DOM inspector correctly shows only one node, while layout displays two of them.
-> layout Nice testcase. After repeatedly clicking the second link (the case that leads to the wrong behavior), you can see that the extra content is not in the DOM: it can't be selected with Ctrl-A. And it doesn't show up in view-selection-source.
Component: DOM → Layout: Block and Inline
The real problem is divs in spans, not spans in divs...
Summary: Inconsistent innerHTML behaviour → {ib}Inconsistent innerHTML behaviour
Works for me on 2.0 and trunk; marking such.
Status: NEW → RESOLVED
Closed: 19 years ago
Flags: in-testsuite?
Resolution: --- → WORKSFORME
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: