Opened 10 years ago
Closed 10 years ago
#14043 closed bug (notabug)
$('#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.
Change History (5)
comment:1 Changed 10 years ago by
comment:2 Changed 10 years ago by
Cc: | timmywil added |
---|---|
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?
comment:4 Changed 10 years ago by
Cc: | timmywil removed |
---|---|
Component: | unfiled → selector |
Owner: | set to timmywil |
Priority: | undecided → high |
Status: | open → assigned |
comment:5 Changed 10 years ago by
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.