Re: Definition of cloneNode method

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