W3C home > Mailing lists > Public > www-dom@w3.org > October to December 1998

Implementing Document.createElement, etc.

From: Deke Smith <deke@tallent.com>
Date: Thu, 8 Oct 98 09:42:01 -0500
To: "DOM list" <www-dom@w3.org>
Message-ID: <1304282776-10339745@tallent.com>
I have a question about all of the Document.create... methods in the DOM 
spec.

My current (mis)understanding is that when an element is created using 
Document.createElement that it is not yet part of the document hierarchy.

If I have an empty Document object (where hasChildNodes() returns false) 
and I use createElement() to create a new Element object, does 
hasChildNodes() still return false?

If so, this would have an interesting implication: these newly created 
nodes can node be found by any of the methods used to traverse the 
document tree, like Node.getChildNodes() in the Java implementation. And 
a Document object that is used to create an Attribute object with 
Document.createAttribute() would not return that Attribute when 
Node.getAttributes() is called in the Java implementation.

My understanding is this: An Element node can be created using a Document 
and that Document would be the Element's ownerDocument (but not parent). 
Once an Element object is placed in the Document tree using a method like 
Node.appendNode(), then and only then would it appear as a child object 
of any other object.

-----------------------------------------------------------------
Deke Smith
Tallent Communications Group, Brentwood TN
deke@tallent.com, 615-661-9878
-----------------------------------------------------------------
" The best way to predict the future is to invent it. " 
       - Alan Kay 
Received on Thursday, 8 October 1998 10:42:08 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Friday, 22 June 2012 06:13:45 GMT