W3C home > Mailing lists > Public > www-dom@w3.org > January to March 1999

Re: document.createElement returned instance

From: Lauren Wood <lauren@sqwest.bc.ca>
Date: Wed, 13 Jan 1999 18:53:24 -0800
Message-ID: <369D5C24.D73C8E66@sqwest.bc.ca>
To: www-dom@w3.org

Terje Norderhaug wrote:
> At 1:38 PM 1/13/99, Christophe Ney wrote:
> >Here is a basic question for which I don't find any answer in the specs:
> >
> >When calling document.createElement("P") should I expect to get
> >an instance of Element, HTMLElement or HTMLParagraphElement ?
> As DOM providdes interfaces NOT class definitions, you should expect to get
> back an object that can be accessed using the HTMLParagraphElement
> interface. What it is an instance of is not specified. The actual class of
> the returned object is implementation dependent and doesn't have to match
> with the names in DOM.

Not necessarily - you may also get back just the Core Element of
type "P", unless you specifically 
a) find out whether the implementation supports the HTML DOM
(hasFeature), and
b) depending on the language, you may need to cast to HTMLElement or

This is so that implementations can manipulate documents that use
the HTML tag set without having to implement the HTML DOM - the
script writer misses out on the convenience functions, but does have
the Core functionality.

Received on Wednesday, 13 January 1999 21:53:41 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 20 October 2015 10:46:05 UTC