RE: Definition of cloneNode method

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