Ticket #7914 (closed bug: duplicate)
.children() returns different result when passing a selector that uses ":first" in some cases
|Reported by:||patrickwhalen||Owned by:|
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.
- Priority changed from undecided to high
- Status changed from new to open
- Component changed from unfiled to selector
- Status changed from open to closed
- Resolution set to duplicate