Ticket #11931 (closed bug: wontfix)
attributeHas selector does not work with jsdom or any other W3C compliant DOM implementation
|Reported by:||janalex||Owned by:|
The issue boils down into the fact that JQuery assumes that DOM's Element.getAttribute will return null if the attribute in question does not exist but according to W3C specification, if the attribute does not exist, the implementation MUST return an empty string (""). Most of the browsers on the market are returning null (i.e., are not W3C compliant) but any W3C compliant DOM implementation will return "", which in turn makes the attributeHas selector think that the attribute exist when it in fact does not. The recommended way to check for attribute existence is using the Element.hasAttribute function or, as a workaround, use the Element.getAttributeNode which returns null when the attribute does not exist.
More details are in the following forum thread: http://forum.jquery.com/topic/attribute-selector-issue.