[whatwg] document.contentType

On Wed, 03 Jun 2009 03:24:29 +0200, Brett Zamir <brettz9 at yahoo.com> wrote:

> Hello,
>
> Regardless of any decision on whether my recommendation for  
> document.contentType to be standardized and made settable on a document  
> created by createDocument() (rather than needing to call the  
> less-than-intuitive doc.open() fix for HTML), I'd still like to  
> recommend standardizing on Mozilla's document.contentType (  
> https://developer.mozilla.org/en/DOM/document.contentType ) for at least  
> being able to get the property.
>
> It can be very useful for JavaScript code or a generic library to offer  
> support for XHTML or HTML, such as conditionally calling  
> getElementsByTagNameNS() (feature detection will not help since a  
> document may still be in HTML even if the browser supports XHTML).

In HTML5, HTML elements in text/html are put in the XHTML namespace and text/html might contain SVG or MathML elements, so you probably want to conditionally call getElementsByTagNameNS based on e.g. the root element's namespaceURI rather than the document's HTMLness.

-- 
Simon Pieters
Opera Software

Received on Tuesday, 2 June 2009 21:23:02 UTC