{ib}Inconsistent innerHTML behaviour

RESOLVED WORKSFORME

Status

()

Core
Layout: Block and Inline
RESOLVED WORKSFORME
16 years ago
11 years ago

People

(Reporter: Rob Jones, Unassigned)

Tracking

Trunk
x86
All
Points:
---
Bug Flags:
in-testsuite ?

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(2 attachments, 1 obsolete attachment)

(Reporter)

Description

16 years ago
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.
(Reporter)

Comment 1

16 years ago
Created attachment 107641 [details]
testcase
Mass-reassigning bugs to dom_bugs@netscape.com
Assignee: jst → dom_bugs

Comment 3

15 years ago
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.



Comment 4

15 years ago
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

Comment 5

15 years ago
Created attachment 129263 [details]
corrected testcase to use unique ids and cleaned up the code

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

Comment 6

15 years ago
Created attachment 142327 [details]
Testcase for bug 182346

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.

Comment 7

15 years ago
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.

Comment 8

15 years ago
-> 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

Comment 10

11 years ago
Works for me on 2.0 and trunk; marking such.
Status: NEW → RESOLVED
Last Resolved: 11 years ago
Flags: in-testsuite?
Resolution: --- → WORKSFORME
You need to log in before you can comment on or make changes to this bug.