cloned nodes are not really separated from original nodes

VERIFIED FIXED

Status

()

P3
normal
VERIFIED FIXED
19 years ago
18 years ago

People

(Reporter: wo, Assigned: jst)

Tracking

Trunk
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

(Whiteboard: [HAVE FIX][nsbeta3+], URL)

(Reporter)

Description

19 years ago
From Bugzilla Helper:
User-Agent: Mozilla/4.72 [en] (Win98; U)
BuildID:    2000033112

changing the properties of a cloned node changes the properties of the original 
node as well.

Reproducible: Always
Steps to Reproduce:
<html><head><title></title></head>
<body>
<h1 id="orig" style="color:#008800;">This is a bug.</h1>
<script>
or=document.getElementById("orig");
co=or.cloneNode(true);
co.style.color="#dddddd";
document.body.appendChild(co);
</script>
</body>
</html>


Actual Results:  both the cloned and the original node are grey.		
					

Expected Results:  only the cloned node should be grey.

Updated

19 years ago
QA Contact: gerardok → janc

Comment 1

19 years ago
setting bug status to new.  confirmed with 071808 mozilla bits on NT
Status: UNCONFIRMED → NEW
Ever confirmed: true

Comment 2

19 years ago
Is there a workaround for this bug for now?
(Assignee)

Comment 3

19 years ago
None that I can think of, unfortunately (except implementing clone in JS on the
page and doing all the work there).

The problem here is that the HTMLElement::clone() implementation simply creates
clones of the attributes in mozilla, and doing that fpr a style attribute only
copies the pointer to the CSSStyleDeclaration() so changing the style of one
element will change the style of all its clones. No easy fix in sight yet, does
anyone know if this break any major sites?
Status: NEW → ASSIGNED
OS: Windows 98 → All
Hardware: PC → All
(Reporter)

Comment 4

19 years ago
currently there are very few "major sites" using DOM methods. Anyway, cloneNode 
is one of the *six* basic node methods in DOM1, so this really has to be fixed 
if Mozilla wants to be anywhere near DOM1 compliant.

Comment 5

19 years ago
What is the resolution for this bug now? target Milestone? This must be 
considered a major bug. It makes cloneNode function totally unusable. Instead 
of copying the pointer for CSSStyleDeclaration() of the source node, how hard 
is it to allocate a new declaration and populate it with the source node's 
attributes and styles, and then point on that new object for the newly created 
node? Probably extra 2 or 3 functions? just guessing didnt check the code.

Bora
Keywords: nsbeta3
Whiteboard: [HAVE FIX][nsbeta3+]
(Assignee)

Comment 6

18 years ago
I just checked in a fix for this so clones are really clones now (AFAIK, at least:)

Marking FIXED.
Status: ASSIGNED → RESOLVED
Last Resolved: 18 years ago
Resolution: --- → FIXED

Comment 7

18 years ago
Verified:
2000-09-28-09-MN6 : Windows
2000-09-26-04-M18 : Mac
2000-09-28-10-MN6 : Linux
 
Status: RESOLVED → VERIFIED
You need to log in before you can comment on or make changes to this bug.