W3C home > Mailing lists > Public > www-dom@w3.org > July to September 1998

Re: Attributes and ownerDocument

From: Ray Whitmer <ray@imall.com>
Date: Mon, 07 Sep 1998 10:14:15 -0600
Message-ID: <35F40657.3B0CE1D3@imall.com>
To: www-dom@w3.org


msabin@cromwellmedia.co.uk wrote:

> According to PR-DOM-Level-1-19980818,
>
>   DOM Attribute objects inherit the Node interface, but
>   since they are not actually child nodes of the element
>   they describe, the DOM does not consider them part of
>   the document tree.
>
> If it weren't for the fact that the immediately following sentence,
>
>   Thus, the Node attributes parentNode, previousSibling,
>   and nextSibling have a null value for Attribute objects.
>
> doesn't mention ownerDocument I would have assumed that not being 'part
> of the document tree' would imply that this attribute would be null too.
>
> Can anyone reassure me that a null value would be conforming?

As the spec says:  "In the DOM Level 1, objects implementing some interface
"X" are created by a "createX()" method on the Document interface; this is
because all DOM objects live in the context of a specific Document."

As it also says:  "Since elements, text nodes, comments, processing
instructions, etc. cannot exist outside the context of a Document, the
Document interface also contains the factory methods needed to create these
objects. The Node objects created have a ownerDocument attribute which
associates them with the Document within whose context they were created."

As it also says, "Provides access to the Document object associated with
this Node. This is also the Document object used to create new Nodes. When
the Node is a Document this is null."

I see no justification whatsoever for believing that ownerDocument would be
null in the case of attributes.  If a user of the API were to rely on
ownerDocument to create new nodes as children of an AttributeNode, it
certainly had better be non-null.

Ray Whitmer
ray@imall.com
Received on Monday, 7 September 1998 12:14:39 GMT

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