Side navigation
#14043 closed bug (notabug)
Opened June 19, 2013 11:12PM UTC
Closed July 04, 2013 05:24PM UTC
$('#root').find(':not(#nested) > li') fails
Reported by: | ngryman | Owned by: | timmywil |
---|---|---|---|
Priority: | high | Milestone: | None |
Component: | selector | Version: | 2.0.2 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
This selector fails with the following html structure:
<ul id="root"> <ul id="nested"> <li></li> </ul> <li></li> <li></li> </ul>
The QSA version works fine.
But if I change the container to a superior level (i.e. body) this works fine:
$('body').find(':not(#nested) > li')
It seems this selector does not work with direct children.
Here is a jsfiddle that illustrates the bug : http://jsfiddle.net/ngryman/tsw4b/.
It fails for any version of jQuery.
Thanks.
Attachments (0)
Change History (5)
Changed June 19, 2013 11:41PM UTC by comment:1
Changed June 20, 2013 12:16AM UTC by comment:2
cc: | → timmywil |
---|---|
status: | new → open |
Confirmed. Sizzle's qSA path returns empty when it seems like it shouldn't be. The cause might be really obvious, but I'm just not seeing it—nor am I seeing a good way to catch it. Can someone else weigh in?
Changed June 20, 2013 05:34PM UTC by comment:3
Oups sorry, I've posted it twice...
Changed July 04, 2013 05:13PM UTC by comment:4
cc: | timmywil |
---|---|
component: | unfiled → selector |
owner: | → timmywil |
priority: | undecided → high |
status: | open → assigned |
Changed July 04, 2013 05:24PM UTC by comment:5
resolution: | → notabug |
---|---|
status: | assigned → closed |
This is not a bug. This is the scope issue with QSA being demonstrated. Sizzle's result is the correct one since #root
should be the context.
Read the selector like this:
find children that are not #nested that contain any li's as direct descendants. #root does not have any children that are not #nested that contain lis. It only contains #nested and lis.
#14044 is a duplicate of this ticket.