Skip to main content

Bug Tracker

Side navigation

#9159 closed bug (duplicate)

Opened May 07, 2011 12:05AM UTC

Closed May 07, 2011 02:24AM UTC

Last modified May 07, 2011 01:58PM UTC

Attribute selectors not working in IE6-7 (really)

Reported by: jamietre Owned by: jamietre
Priority: high Milestone:
Component: selector Version: 1.6
Keywords: Cc:
Blocked by: Blocking:

This is reopening Ticket #9156. Sorry about the confusion - it has been difficult to determine the problem since I can't use jsFiddle with IE6.

There is a bug in the Sizzle code that is used when .querySelectorAll is not available to select attributes that have no value.

Original code at line 4465 in 1.6.0:

4464   !check ?
4465   value && result !== false :
4466   type === "!=" ?

for a "has attribute" selector like "[someattribute]", at this point value="" if the attribute exists but has no value. In this case it should match. If the attribute does not exist, then value=null. This test causes the selector to fail because "" is not truthy.

This code needs to test for an empty string as a valid value when !check is true (meaning we're only testing for existence of an attribute). Here is a proposed correction.

4464   !check ?
4465   (value || value==="") && result !== false :
4466   type === "!=" ?

There are other inconsistencies related to attribute handling at least in IE6 that I have not completely isolated yet. e.g.


causes IE6 to render "disabled" with no value, and other browsers to render disabled="disabled". When testing


IE6 returns "true" and other browsers return "disabled."

This could be a problem with how the attribute is set (versus tested) but I haven't been able to isolate it completely.

Attachments (0)
Change History (6)

Changed May 07, 2011 12:29AM UTC by timmywil comment:1

component: unfiledselector
owner: → jamietre
status: newpending

Thanks for taking the time to contribute to the jQuery project! Please provide a reduced test case on that reproduces the issue experienced to help us assess your ticket.

Additionally, test against the jQuery (edge) version to ensure the issue still exists.

Changed May 07, 2011 12:31AM UTC by timmywil comment:2

I created this test case to try and reproduce the issue with the disabled attribute and was unable in 1.6 and jQuery (edge).

Changed May 07, 2011 01:37AM UTC by jamietre comment:3

status: pendingnew

I can't get anything in jsfiddle to run in IE6. Are you actually able to test this fiddle in a browser that doesn't have querySelectorAll support in jsFiddle? If so I'd love some tips because I can't, which is why I've been posting external links.

Here is my very, very simple page showing these two issues:

Please just look at the source to that page. Nothing could be simpler. I include only jQuery and there is nothing else outside the test code. The selector does not work in IE6. Likewise, the "disabled" thing returns different results.

I was able track down the bug by disabling the Sizzle code that uses document.querySelectorAll and forcing it to use it's own implementation no matter what, and debugging in Chrome.

Changed May 07, 2011 02:24AM UTC by timmywil comment:4

priority: undecidedhigh
resolution: → duplicate
status: newclosed

I see. Well, this is actually two different issues. It's strange that I am unable to reproduce the behavior your test page shows for the disabled attribute, however when I include the git version of jQuery on your page, it works as expected. Nevertheless, I recommend using prop for getting/setting disabled.

As for the selector bug, that is a duplicate. So since the first has been fixed, I'll direct this ticket to the selector one.

Changed May 07, 2011 02:24AM UTC by timmywil comment:5

Duplicate of #7770.

Changed May 07, 2011 01:58PM UTC by jamietre comment:6

OK, I'm glad the attribute selector bug is being addressed already.

In taking your advice to use the new "prop" instead of "attr" I came across some some problems with that as well, I posted a new bug report