cloneNode is not copying the style attribute

VERIFIED DUPLICATE of bug 137428

Status

()

VERIFIED DUPLICATE of bug 137428
17 years ago
10 years ago

People

(Reporter: pieter, Assigned: jst)

Tracking

Trunk
x86
Windows 2000
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment)

(Reporter)

Description

17 years ago
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.0rc1)
Gecko/20020417
BuildID:    2002041711

The test case below (available as attachment further down) illustrates the problem.

Expected result: There should be two 100x100 pixel boxes displayed side by side,
a green one to the right of a red one. The popup message should say “copy
position/width: absolute, 100px”.

Actual result: The green box created by cloneNode is not displayed. The popup
message shows that the cloned node does not have two style attributes,
displaying “copy position/width: ,”

Cause of the wrong result is illustrated by the alert popup - the node created
using cloneNode does not have the style attribute values from the source node.

This test works ok in Netscape 6.2, and I believe worked in Mozilla 0.9.5, build
5.0.0.9.5.2001101120.

Note that it makes no difference if the cloneNode call is “deep” or not
(parameter true vs. false), the problem occurs either way.

Sample page to illustrate problem:
<HTML>
<HEAD></HEAD>
<BODY>
<DIV id="container">
 <DIV id="copyit" style="position:absolute; background-color:red;
          top:20px; left:20px; width:100px; height:100px;">
 </DIV>
</DIV>
<SCRIPT language="JavaScript">
  var copy = document.getElementById("copyit").cloneNode(true);
  copy.style.left = "120px";
  copy.style.backgroundColor = "green";
  document.getElementById("container").appendChild(copy);
  alert("copy position/width: " + copy.style.position + ", " + copy.style.width);
</SCRIPT>
</BODY>
</HTML>
(Reporter)

Comment 1

17 years ago
Created attachment 81081 [details]
test case illustrating the bug
Yeah... this was a recent regression; it's now fixed on both branch and trunk. 
Thanks for the bug report, Pieter!

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

Comment 3

17 years ago
Wow, that was quick! And great that it is fixed already. My apologies for not 
seeing the duplicate (I missed it in my search on cloneNode, I guess I did not 
search correctly.) Thank you!
No, you did search correctly.  The summary didn't have cloneNode in it until a
couple minutes before Boris duped the bug.  I asked him to add cloneNode to the
summary of the original and then dupe this one (which I could not find either).

Verifying duplicate.
Status: RESOLVED → VERIFIED
Yep.  What Christopher said.  I was an idiot and didn't add cloneNode to the
other bug's summary at the right time (like when I figured out it was caused by
cloneNode.... :) )

Updated

10 years ago
Component: DOM: Core → DOM: Core & HTML
QA Contact: stummala → general
You need to log in before you can comment on or make changes to this bug.