Re: Detecting support for a given HTML5 feature through JS

On Jul 15, 2007, at 3:21 PM, Doug Schepers wrote:

>
> Hi, Henri-
>
> Henri Sivonen wrote:
>> On Jul 15, 2007, at 20:40, Jon Barnett wrote:
>>> Hixie pointed out that you can detect support for certain features
>>> using Javascript [1], such as writing PING as uppercase in the DOM,
>>> and then checking the HTMLAnchorElement.ping property  
>>> (lowercase).  I
>>> suspect the same logic can apply to new input/@type values - use
>>> <input type="date">, and then check the HTMLInputElement.type  
>>> property
>>> for either "date" or "text".
>> This is the best way because the test for the existence of the  
>> implementation involves testing the implementation itself.
>
> In certain cases, this is a reasonable statement.  But it isn't  
> universally applicable.  For instance, if you'll look at another  
> MathML testcase [1], you'll see the problem.

Testing for the property or method directly is the best way to test  
for DOM interfaces (it's more fine-grained than anything hasFeature  
will give you) but it doesn't  seem that great a way to test for  
implementation of markup interfaces and attributes. However, this is  
only relevant for elements and attributes that have a rendering effect  
which can't be seen in CSS, or a behavior effect that is not tied to  
any scripting interfaces. For HTML5 itself, I think that is a pretty  
small subset.

Regards,
Maciej

Received on Monday, 16 July 2007 05:38:10 UTC