Closed Bug 45680 Opened 24 years ago Closed 24 years ago

cloned nodes are not really separated from original nodes

Categories

(Core :: DOM: Core & HTML, defect, P3)

defect

Tracking

()

VERIFIED FIXED

People

(Reporter: wo, Assigned: jst)

References

()

Details

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

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.
QA Contact: gerardok → janc
setting bug status to new.  confirmed with 071808 mozilla bits on NT
Status: UNCONFIRMED → NEW
Ever confirmed: true
Is there a workaround for this bug for now?
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
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.
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+]
I just checked in a fix for this so clones are really clones now (AFAIK, at least:)

Marking FIXED.
Status: ASSIGNED → RESOLVED
Closed: 24 years ago
Resolution: --- → FIXED
Verified:
2000-09-28-09-MN6 : Windows
2000-09-26-04-M18 : Mac
2000-09-28-10-MN6 : Linux
 
Status: RESOLVED → VERIFIED
Component: DOM → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.