Re: Node.ownerDocument property: always defined?


I find the spec to be very clear.  Whatever document that the node was created from, no matter how it was created, will have it's ownerDocument property set to that document.

The reason why Document nodes do not apply is that it is created by the parser engine, not a document.  A document is not owned by a document.

The reason why a DocumentType node does not have an owner document (I am assuming here) is because it is also a stand-alone document.  This document is used to describe the tag structure rules for a HTML or XML document.  Thus a DocumentType node is not owned by a document.

Jeff Yates.

---------- Original Message ----------------------------------
From: David Flanagan <>
Date: Fri, 13 Jul 2001 15:30:16 -0700

The DOM Level 2 spec has this to say about Node.ownerDocument:

> The Document object associated with this node. This is also the Document
> object used to create new nodes. When this node is a Document or a
> DocumentType which is not used with any Document yet, this is null.

This specifies a couple of cases when ownerDocument is null, but it is
not clear if these are the only times that it is null.  For example,
when I create a new Element or other node with one of the
Document.createXXX() methods is the resulting node required to have its
ownerDocument property set?

      David Flanagan

Jeff Yates


Received on Friday, 13 July 2001 19:41:00 UTC