Re: Should Document.cloneNode() work in Level 1?

I think there might be a very nice solution here somewhere.

How does this look?

We just add Document.transferNode(Node node) as Ray suggested and have the
user use Node.cloneNode() with it if he is cloning over to a new document.

Node originalNode; // this node is in the tree structure (parentNode !=
null)
Document destinationDoc;

destinationDoc.transferNode(originalNode.cloneNode(false));
    // transfer a shallow clone

destinationDoc.transferNode(originalNode.cloneNode(true));
    // transfer a deep clone

destinationDoc.transferNode(originalNode);
    // transfer the original node

Comments?

Don Park
Docuverse

-----Original Message-----
From: Ray Whitmer <ray@imall.com>
To: www-dom@w3.org <www-dom@w3.org>
Date: Tuesday, September 08, 1998 6:23 PM
Subject: Re: Should Document.cloneNode() work in Level 1?


>Don Park wrote:
>
>> >newDoc.createCopy(node, false); // for a shallow copy
>> >newDoc.createCopy(node, true); // for a deep copy
>>
>> I have no problem with this proposal particularly because it shifts the
>> responsibility of copying to the destination document.  It feels right.
>
>I would prefer a method at the doc level, but one which has the option of
>either cloning if the document is incompatible or transforming it if the
>documents are compatible.  Only the retured node and not the original
>would be usable after the operation.
>
>I would call this transferNode(node) // always a deep transfer.
>
>Actually, given my current model's shared underlying data model, I can
>clone faster than I can mutate the original reference to have new
>ownerDocuments, since clones share the original data.  I only prefer this
>other approach to allow other implementations to efficiently transfer
>documents between compatible implementations.  If no one else wants it,
>fine.
>
>I didn't hear opinions whether document.cloneNode(deep) should clone the
>document itself or raise an exception.  This is quite different from both
>cloneNode or transferNode on a child, because it creates a new
>ownerDocument rather than confining to or transferring between existing
>ownerDocument's.  I think we need something like cloneNode to work at the
>document level.
>
>Ray Whitmer
>
>
>

Received on Wednesday, 9 September 1998 01:06:01 UTC