Attribute selectors not working in IE6-7 (really)
|Reported by:||jamietre||Owned by:||jamietre|
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.
Change History (6)
comment:1 Changed 6 years ago by timmywil
- Component changed from unfiled to selector
- Owner set to jamietre
- Status changed from new to pending
comment:4 Changed 6 years ago by timmywil
- Priority changed from undecided to high
- Resolution set to duplicate
- Status changed from new to closed