- From: Stephen R. Savitzky <steve@crc.ricoh.com>
- Date: 08 Sep 1998 13:37:11 -0700
- To: "Don Park" <donpark@quake.net>
- Cc: <www-dom@w3.org>
"Don Park" <donpark@quake.net> writes: > >A better alternative would be to put this on Document rather than Node: > > > > Node cloneNode(Node original, boolean deep) > > All nice and dandy except for the weird look code: On second thought, it should be called something different, like createCopy. > Document doc = node.getOwnerDocument(); > doc.cloneNode(node, doc); newDoc.createCopy(node, false); // for a shallow copy newDoc.createCopy(node, true); // for a deep copy > It just does not look as natural as: > > Node newNode = oldNode.cloneNode(true, null); // for same doc > Node newNode = oldNode.cloneNode(true, someOtherDoc); We should keep the existing Node method cloneNode, with no added document parameter. That way if you want to add a duplicate node to the same document you use cloneNode; if you want to creat a copy in another document you use createCopy. newParent.appendChild(newParent.getOwnerDocument().copyNode(oldNode, true)); (as opposed to: newParent.appendChild(oldNode.cloneNode(true, newParent.getOwnerDocument())); under the other proposal.) My way looks more natural if you're doing a mixture of node copying and node creation. You get the owner document once and perform a series of create operations. Something like this is really essential if you're in a system (like the one I'm building) which permits different DOM implementations for different documents. -- 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 Tuesday, 8 September 1998 16:30:51 UTC