Three Monkeys, Three Typewriters, Two Days

September 27, 2010

How not to do object-detection sniffing

We've had a few bug reports about Github's search boxes looking all wrong on trunk. The reason for this is broken browser-sniffing masquerading as object-detection on Github.

In particular, Github assumes that only browsers whose input elements have an "onsearch" property (which seems to be some sort of Webkit proprietary extension) support the "placeholder" attribute on inputs. Of course Gecko 2.0 supports the "placeholder" attribute but its inputs do not have an "onsearch" property.

The right way to do this sniffing is to check whether an input has a "placeholder" property; if it does, assuming that the "placeholder" attribute is supported is reasonable. But using detection of one object as a proxy for the presence or absence of another one is just broken.

If someone has contacts at Github, please let them know about this problem?

Posted by bzbarsky at September 27, 2010 2:19 PM