Opened 10 years ago
Closed 10 years ago
#12830 closed bug (duplicate)
find('option[selected]') and find('option').filter('[selected]') give different results
Reported by: | 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:
- Go to Live demo (see link above)
- Choose any option in select dropdown (other than default option)
- Click button to trigger the jQuery expressions.
- 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.
Change History (2)
comment:1 Changed 10 years ago by
Component: | unfiled → selector |
---|---|
Milestone: | None → 1.9 |
Priority: | undecided → low |
Status: | new → open |
comment:2 Changed 10 years ago by
Resolution: | → duplicate |
---|---|
Status: | open → closed |
Note: See
TracTickets for help on using
tickets.
Duplicate of #11115.
Ah, the boolHook rears its ugly head: http://jsfiddle.net/ugXtx/13/
querySelectorAll
gets it right, andjQuery.attr
doesn't.