Side navigation
#12600 closed bug (fixed)
Opened September 24, 2012 08:30PM UTC
Closed December 14, 2012 03:37PM UTC
jQuery('select').is('[value="value"]') works inconsistently depending on number of elements returned
Reported by: | dschoutens@gmail.com | Owned by: | gibson042 |
---|---|---|---|
Priority: | blocker | Milestone: | 1.9 |
Component: | attributes | Version: | 1.8.0 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
I have distilled the issue as much as possible in a jsFiddle: http://jsfiddle.net/Mj23Q/
Say we've got a jQuery object saved to a variable, x.
If x contains multiple select elements and at least one of them has a value, "1", then:
x.is('[value=1]')
will return true, since at least one select element matches the value attribute selector given. However, if x only contains a single element, and that element is a select with a value of "1", the same function returns false.
I tested and was able to reproduce this in Chrome 21, Chrome 24 (Canary), Firefox 15, and Internet Explorer 9 for all versions of jQuery provided in jsFiddle.
Sorry if this is a duplicate bug, but I really tried to find an existing bug report. My search-fu might be a little off today.
Attachments (0)
Change History (12)
Changed September 24, 2012 09:04PM UTC by comment:1
owner: | → rwaldron |
---|---|
status: | new → assigned |
Changed September 24, 2012 10:06PM UTC by comment:2
Not 100%, but this change might be the issue: https://github.com/jquery/sizzle/commit/6e524a5915a8a5dda1969898749c81d0fae64e6e
(this is mostly a note to myself as I dig through this)
Changed September 25, 2012 02:49PM UTC by comment:3
This might help: it seems the bug is not specific to the .is() function, but also affects .filter() (at least...)
I updated the jsFiddle to demonstrate: http://jsfiddle.net/Mj23Q/13/
Changed September 25, 2012 02:50PM UTC by comment:4
Replying to [comment:3 anonymous]:
This might help: it seems the bug is not specific to the .is() function, but also affects .filter() (at least...) I updated the jsFiddle to demonstrate: http://jsfiddle.net/Mj23Q/13/
That was me... forgot to specify my email in my comment.
Changed October 15, 2012 05:50PM UTC by comment:5
component: | unfiled → attributes |
---|---|
priority: | undecided → low |
Changed November 29, 2012 05:57AM UTC by comment:6
_comment0: | The expectations in the comments of that fiddle are erroneous... `select[value=…]` shouldn't match anything, because most select elements—and those in particular—don't have attributes named "value". \ \ This ticket is the `valHook` equivalent of #11115: native Sizzle always gets it right, jQuery only does so when `jQuery.filter` calls a qSA-backed `matchesSelector` in the single-element case: http://jsfiddle.net/Mj23Q/43/ → 1354169255481182 |
---|---|
blocking: | → 11115 |
The expectations in the comments of that fiddle are erroneous... select[value=…]
shouldn't match anything, because most select elements—and those in particular—don't have attributes named "value".
This ticket is the attrHooks
equivalent of #11115: native Sizzle always gets it right, jQuery only does so when jQuery.filter
calls a qSA-backed matchesSelector
in the single-element case: http://jsfiddle.net/Mj23Q/43/
Changed December 04, 2012 04:49AM UTC by comment:7
milestone: | None → 1.9 |
---|---|
priority: | low → blocker |
Changed December 04, 2012 04:51AM UTC by comment:8
The hook should be moved to https://github.com/jquery/jquery-compat/.
Changed December 05, 2012 02:06AM UTC by comment:9
owner: | rwaldron → gibson042 |
---|
Reassigning to gibson042, seems like you have a better handle on this
Changed December 08, 2012 09:30PM UTC by comment:10
Changed December 09, 2012 12:09AM UTC by comment:11
#11735 is a duplicate of this ticket.
Changed December 14, 2012 03:37PM UTC by comment:12
resolution: | → fixed |
---|---|
status: | assigned → closed |
Fix #12600: don't use value property in place of value attribute. Close gh-1063.
Changeset: 2c40fdd4a852fe6ee16feaa3bb6d7d49c7a02606