Thursday, February 21st, 2008
In his feature detection article he walks through a myriad of approaches with pros and cons:
Feature testing is not easy and there is no one right answer. From a practical stand point, the more strict your tests are the more likely your code runs only when it will run successfully.
There are some obvious wrong answers like
navigator.UserAgentinference, unrelated execution inference and unrelated object inference. Check the library you are using. Does it use any of these techniques? I have seen many uses of these techniques in mainstream libraries even where there is a well known, better test available. The mainstream libraries cannot consider claiming to be state of the art until they remove these bad practices at the very least.
The above discussion focuses on tests against a single object to infer if that object or similar ones work. Sometimes it may be necessary to use multiple objects together to make an inference about one object. An example for scroll reporting. Even when using multiple host objects in a test the three
isHost*functions will be useful.
Feature detection is not easy, but as professionals, we should use the best tests we can.
In his cross browser widget article he goes further to create a library to handle cross browser widgets:
I’ve tried the tabbed pane in all the browsers I have and it is either enabled an works or it is disabled and doesn’t throw errors. I suspect there is a browser out there somewhere that will throw an error. That is just the nature of the cross-browser challenge. In a perverse masochistic way, I somewhat hope someone can find a browser in which this widget breaks. That is one way we can continue to improve.
Posted by Dion Almaer at 9:03 am