- From: Stephen R. Savitzky <steve@crc.ricoh.com>
- Date: 09 Sep 1998 11:22:41 -0700
- To: Ray Whitmer <ray@imall.com>
- Cc: www-dom@w3.org
Ray Whitmer <ray@imall.com> writes: > 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. This would be a totally different operation. It _would_ be useful, however, since you could use it to relocate a node without having to worry about whether you're moving it between documents. Actually what I would find more useful is the flip-side of this: copy the node if it is type-incompatible or already part of an existing complete document, but simply transfer it if it belongs to a DocumentFragment. The motivation for this is that sometimes you are constructing a document out of nodes that result from a traversal of an existing document (which you don't want to modify), but sometimes you are creating nodes on the fly. It's desirable not to have to know the difference. > 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. I agree, but it's probably necessary to make it clear that that's what's happening. Note that with document.createCopy it is possible to specify explicitly what deep-copying a document means (shallow-copy the Document node, then recursively createCopy all of the children) -- Stephen R. Savitzky Chief Software Scientist, Ricoh Silicon Valley, Inc., <steve@rsv.ricoh.com> California Research Center voice: 650.496.5710 fax: 650.854.8740 URL: http://rsv.ricoh.com/~steve/ home: <steve@starport.com> URL: http://www.starport.com/people/steve/
Received on Wednesday, 9 September 1998 14:16:47 UTC