Side navigation
#7914 closed bug (duplicate)
Opened January 06, 2011 06:10PM UTC
Closed July 12, 2011 04:51PM UTC
Last modified July 12, 2011 04:51PM UTC
.children() returns different result when passing a selector that uses ":first" in some cases
Reported by: | patrickwhalen | Owned by: | |
---|---|---|---|
Priority: | high | Milestone: | 1.next |
Component: | selector | Version: | 1.4.4 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
When passing a selector to $('#div2').children()
in the form of [parent] > [child]
...
- if the
:first
selector is added to[parent]
, - and there are no immediate children that match
[child]
, - but there is an immediate child that matches
[parent]
, - and
[parent]
has an immediate child that matches[child]
... jQuery/Sizzle will return [parent]
.
<div id='div2'> <ul id='ul2'> <li>4</li> <li>5</li> <li>6</li> </ul> </div>
// Using "ul > li" selector returns an empty set (as it should) $('#div2').children('ul > li'); // Using "ul:first > span" selector returns an empty set (as it should) $('#div2').children('ul:first > span'); // Using "ul:first > li" selector returns the UL even though we're targeting LI $('#div2').children('ul:first > li');
NOTE: The same applies to :last
and :eq(0)
, but not :first/last/nth-child
. I haven't tested beyond this.
Attachments (0)
Change History (4)
Changed January 06, 2011 06:23PM UTC by comment:1
Changed January 07, 2011 03:11PM UTC by comment:2
component: | unfiled → selector |
---|---|
priority: | undecided → high |
status: | new → open |
This looks valid and probably is a bug in Sizzle, this can be deduced from the fact that changing ul:first > li
to ul:first-child > li
yield different results (no-qSA vs. qSA use).
Changed July 12, 2011 04:51PM UTC by comment:3
resolution: | → duplicate |
---|---|
status: | open → closed |
We'll likely be fixing this in an upcoming Sizzle rewrite.
This bug seems to have appeared in jQuery 1.4.3, and is the result of a fix where previous versions returned the
[child]
elements.