W3C home > Mailing lists > Public > www-dom@w3.org > January to March 1999

RE: Definition of cloneNode method

From: Mike Champion <mcc@arbortext.com>
Date: Mon, 04 Jan 1999 23:09:39 -0500
Message-Id: <>
To: "Jeff Mackay" <jmackay@vtopia.com>, <www-dom@w3.org>
At 08:09 PM 1/4/99 -0600, Jeff Mackay wrote:

>ID attributes also need to be examined.  What happens when I clone a set of
>nodes having unique IDs?  Are the IDs cloned as well? Under the current
>definition, I would presume so.
>What happens when I copy those cloned nodes with their duplicate IDs to
>another section of the document?
>Even more complicated is nodes with IDREF attributes, when the value of an
>IDREF points to a node that is also being cloned.

Be careful not to read too much into the spec.  I remember that this
subject did come up (probably by someone objecting to the cloneNode()
method!); my recollection is that we decided that cloneNode() creates an
exact duplicate Node, and it is the user's job to fix up IDs to be unique
and IDREFs to point to the desired node.  (As I recall, all this requires a
fairly deep understanding of the current DTD to really do properly, and it
seems unreasonable to have the DOM implementor handle this all in the
general case).

You can't count on a DOM implementation doing anything more than what a
very literal interpretation of the spec insists that it do, and a literal
reading of the spec says that cloneNode() creates an exact duplicate, with
all attribute values in the result identical to those in the original, with
no special treatment for ID or IDREF attributes.

Mike Champion
Received on Monday, 4 January 1999 23:10:41 UTC

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