Re: [DOMCore] createElement() and HTML-specific element interfaces

Hi David,

On 08/09/2011 05:56 PM, David Flanagan wrote:
> I can't see anything in the DOMCore spec that references the fact that
> HTML defines lots of Element subclasses and that createElement('table'),
> for example, is supposed to return an instance of HTMLTableElement.
>
> Also, it is unclear to me what should happen if d is a document returned
> by createDocument (not createHTMLDocument) and I call
> d.createElement("table"). The spec is clear that the element will use
> the HTML namespace, but it is not clear whether the resulting object is
> instanceof HTMLTableElement or just Element.
>
> createElementNS() is similarly underspecified: under what circumstances
> does it create instances of the HTML-specific interfaces defined in the
> HTML spec?

Indeed, this is left up to the HTML specification. It defines [1] that 
elements must implement the interface listed in the definition box, 
which is HTMLTableElement for table elements [2].

HTH
Ms2ger

[1] http://www.whatwg.org/html/#element-definitions
[2] http://www.whatwg.org/html/#the-table-element

Received on Tuesday, 9 August 2011 16:21:24 UTC