- From: Sander Bos <sander@x-hive.com>
- Date: Mon, 12 Nov 2001 18:23:52 +0100
- To: "www-dom list" <www-dom@w3.org>
> DOM Level 1 didn't specify how the root element was created, > but I believe > it did say it couldn't be removed. > > DOM Level 2 said the root element could be created only at > the time the > document was created, and still didn't permit removing it. > The rationalle > has to do with potentially using information about the root element's > namespace and localname, along with the document type information, to > select among different DOM implementations/subclasses. In our implementation, we do not allow document.removeChild(document.getDocumentElement()); , however we do allow document.replaceChild(someElement, document.getDocumentElement()); Since the replaceChild spec text does not say explicitly that part of its action is removing the old child, I think this adheres to the specification (and if it doesn't, then we break the spec). We had two customers asking for this precisely because of the reason given by Garret, namely that it is very annoying to have to copy over attributes from another element (both did not want to change the document element name). Their usage was for making a copy of a document: Document copyDoc = impl.createDocument(null, "dummy", null); Node copy = copyDoc.importNode(sourceDoc.getDocumentElement()); copyDoc.replaceChild(copy, copyDoc.getDocumentElement()); Without replaceChild, this would take a lot more than three lines. Kind regards, --Sander.
Received on Monday, 12 November 2001 12:24:36 UTC