Side navigation
#12830 closed bug (duplicate)
Opened November 02, 2012 01:48AM UTC
Closed November 21, 2012 08:54PM UTC
find('option[selected]') and find('option').filter('[selected]') give different results
Reported by: | pang@jassolutions.com.hk | Owned by: | |
---|---|---|---|
Priority: | low | Milestone: | 1.9 |
Component: | selector | Version: | 1.8.2 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
- Bug Description:
find('option[selected]')
and
find('option').filter('[selected]')
give different results after user changed selection in dropdown manually. I believe that they are just 2 different ways to write the same expression and therefore should always return the same result.
- jQuery versions: 1.8.2, 1.7.2, 1.6.4
- Browsers: Chrome, Firefox, IE9, Opera, Safari
- OS: Windows, Mac, iOS
- Live demo: http://jsfiddle.net/ugXtx/9/
- Expected behaviour: The 2 different jQuery expressions always give the same result.
- Actual behaviour: They give different results after user changed selection in dropdown manually
- Steps to reproduce:
1. Go to Live demo (see link above)
1. Choose any option in select dropdown (other than default option)
1. Click button to trigger the jQuery expressions.
1. Result is shown
As you can see, they are different.
- More details (source code, test results, discussion, etc.): http://stackoverflow.com/questions/13137737
- Note: I know I can use
:selected
to get the current selection, but that's not the point. The point is that jQuery (or Sizzle?) behave inconsistently when the same selector is written in different ways.
Attachments (0)
Change History (2)
Changed November 21, 2012 06:51PM UTC by comment:1
component: | unfiled → selector |
---|---|
milestone: | None → 1.9 |
priority: | undecided → low |
status: | new → open |
Changed November 21, 2012 08:54PM UTC by comment:2
resolution: | → duplicate |
---|---|
status: | open → closed |
Duplicate of #11115.Ah, the boolHook rears its ugly head: http://jsfiddle.net/ugXtx/13/
querySelectorAll
gets it right, and jQuery.attr
doesn't.