setting of embedded divs innerHTML using javascript fails

VERIFIED DUPLICATE of bug 26179

Status

()

Core
DOM
VERIFIED DUPLICATE of bug 26179
17 years ago
5 years ago

People

(Reporter: Vinny Joe, Assigned: jst)

Tracking

Trunk
x86
Windows 2000
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

(Reporter)

Description

17 years ago
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:0.9.6) Gecko/20011120
BuildID:    2001112009

If you have a div (child) embedded in another div (parent), and try to set the
childs innerHTML using document.getElementById("parent").firstChild.innerHTML,
changes are not visible in the browser. However, if you access the child
directly by name [document.getElementById("child").innerHTML], all is well. Best
illustrated with the following html code:

<html>
<head>
<title>innerhtml check</title>

<script type="text/javascript" language="javascript">

function writeToChildOf(obj) 
{
	var oListHandle = document.getElementById(obj).firstChild;
	oListHandle.innerHTML = "Child Div innerHtml Changed. No bug.";
}

</script>

</head>

<body>

<a href="javascript://" onclick="writeToChildOf('aParent')">Test</a> 	

<div id="aParent">
	<div id="aChild"> Click on Test to change this message. No change => bug. </div>
</div>

</body>
</html>


Reproducible: Always
Steps to Reproduce:
Load above html code into browser. Click on Test.

Actual Results:  
Test
Click on Test to change this message. No change => bug.


Expected Results:  
Test 
Child Div innerHtml Changed. No bug.

The problem exists not just with embedded DIVs, but also SPANS embedded  in a
DIV. ie, <div><span>blah</span></div>.

Works as expected under IE 6. Since innerHTML was copied over from IE, I guess
compliance with IE behaviour is more or less what people would come to expect.
innerHTML is working fine.  firstChild for the outer div, however, is a Text
node corresponding to the line break you have in the source, not an Element
node.  Text nodes don't have a way to set their innderHTML

*** This bug has been marked as a duplicate of 26179 ***
Status: UNCONFIRMED → RESOLVED
Last Resolved: 17 years ago
Resolution: --- → DUPLICATE

Comment 2

17 years ago
Boris, you're too fast for me ;-)
VERIFIED dup.
Status: RESOLVED → VERIFIED

Updated

16 years ago
QA Contact: lchiang → ian
Component: DOM: Mozilla Extensions → DOM
Product: Core → Core
You need to log in before you can comment on or make changes to this bug.