W3C home > Mailing lists > Public > www-dom@w3.org > October to December 1998

Re: Definition of cloneNode method

From: Ray Whitmer <ray@imall.com>
Date: Wed, 30 Dec 1998 10:25:06 -0700
Message-ID: <368A61F1.57A56944@imall.com>
To: David Beech <DBEECH@us.oracle.com>
CC: www-dom@w3.org
David Beech wrote:

> Just to check my understanding of shallow cloneNode - this will copy the
> chosen node, including its childNodes attribute, which (in IDL as in Java)
> consists of references to other objects, i.e. to the original child nodes.
> Hence by following the parentNode reference in the child, and then the
> parentNode reference again, one can arrive at the original parent (if any)
> of
> the cloned node, even though parentNode is null in the clone.

I have trouble following your description or your intent.

The deep clone copies the hierarchy producing a set of new nodes which bear a
1:1 correspondence to the original hierarchy from the cloned node on down, but
none of which point to the original nodes that were cloned as parents, siblings,
or children.

The childNodes attribute of the cloned node does not refer to any children of
the original node, nor would this be possible without destroying the original
hierarchy, since nodes cannot be children of multiple parents.  The intent of
clone is not to destroy the original hierarchy.  Rather, it refers to clones of
the children of the original node, which in turn refer to the clone of the
original parent as their parent.  Only the root cloned node has a null parent.

Ray Whitmer
Received on Wednesday, 30 December 1998 12:26:36 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 20 October 2015 10:46:05 UTC