HTML and CSS Reference
In-Depth Information
The undetectables
As we've already alluded to, there are definitely nuances in writ-
ing a polyfill for one technology to the next. However, there are
also the black holes, those undetectable technologies.
A simple example of an “undetectable” is a technology that
gives a false positive when tested.
Let's take, for example, the contenteditable attribute from Chap-
ter 2. If you test for the attribute using the methods we've seen
so far, it will tell you that contenteditable is supported, but really
the problem is that on a device like Safari Mobile (pre-iOS 5) the
keyboard doesn't actually focus to the editable area, so in reality
it's not supported, regardless of the feature detection test.
It's hard to say exactly what is and isn't available to feature test.
So long as you're testing your polyfill against all the browsers
your site plans to support, you'll find whether or not the feature
can be truly and reliably detected.
If you'd like a head start on those undetectables and determin-
ing the environments in which they're undetectable, the Mod-
ernizr project (
Undetectables ) has a page dedicated to those technologies.
If a feature can't be detected, what's the solution? Well, it's
nasty, but one answer could be to browser sniff. It's an unreli-
able technique because the browser doesn't always tell the
truth about its version or even its name—even today Microsoft
Internet Explorer claims to be a Mozilla browser! What you
should also be wary of with user agent sniffing is that there are
future browser versions that your code might pick up incorrectly.
It's a very wobbly ground on which to rely.
Where to ind polyills
As with most JavaScript snippet libraries, polyfills are scattered
around the Web, but Paul Irish, like a superhero flying out of the
deepest, darkest corners of the Web, started a wiki page col-
lecting all the ones he could find (
Modernizr/wiki/HTML5-Cross-Browser-Polyills ) . Since this page
is a wiki, it has grown over time with many contributions from
the web development community, including our fine selves, with
Search WWH ::

Custom Search