Insights and discoveries
from deep in the weeds

Thursday, May 26, 2011

jQuery "has attribute" selector bug revisited: 1.6.1

In my last post I commented on problems with the jQuery "has attribute" selector in older browsers, specifically IE6 & 7 (and maybe a very old Firefox).

In 1.6.1 the functionality of attr has been returned to normal, which is good. The "has attribute" selector, unfortunately, is still broken. Run this fiddle in IE6 or 7. (Yeah I know jsFiddle barely works in IE6 and 7, but if you ignore the js errors you can still see the results).

Example 1: "nohref" attribute in "map" tag

The one that's being found is actually the invalid one ("nohref" is a property, and shouldn't have a value). Here's the fiddle showing this:

Example 2: "nohref" - both valid this time

Interestingly, it works sometimes. With "checked", the attribute is properly found either way:

Example 3: "checked" -- works!

With "custom" properties it never works, like with "nohref". So anyway, I'm still using the double-selector to properly check for 'has attribute' to be sure:


1 comment:

  1. Hello Jamie,

    I run a small start-up in DC.
    I wanted to ask you a question about Imagemapster, can you please drop me a line:
    Aron (at) SimpleTick (.) com