Bug Tracker

Opened 13 years ago

Closed 13 years ago

Last modified 13 years ago

#6723 closed bug (duplicate)

:has fails in combination with :gt

Reported by: acdha Owned by:
Priority: low Milestone: 1.next
Component: selector Version: 1.4.4rc
Keywords: Cc:
Blocked by: Blocking:

Description

Assuming a list like:

<ul><li></li><li></li><li></li></ul>

expressions like jQuery("ul:has(li:gt(1)") will fail to match anything.

I was going to write a test-case but there's a nice one here which I couldn't find referenced in the bug tracker: http://kruisit.nl/jquerybugs/?version=nightly

There is a workaround:

jQuery("ul").has("li:gt(1)")

or

jQuery("li:gt(1)").parent()

Change History (5)

comment:1 Changed 13 years ago by acdha

Note for anyone else trying: the first workaround with .has() is not correct as it will match as long as there are more than the :gt() count elements anywhere on the entire page, not just under the selected <ul>. To get this to work reliably with jQuery 1.4.2 requires something like this:

jQuery("ul").each(function (i) { 
    if ($(this).children("li").length > 10) { 
        … 
    }
});

comment:2 Changed 13 years ago by Rick Waldron

Milestone: 1.4.3
Priority: low
Status: newopen
Version: 1.4.21.4.4rc

comment:3 Changed 13 years ago by danheberden

Milestone: 1.next

comment:4 Changed 13 years ago by danheberden

Resolution: duplicate
Status: openclosed

comment:5 Changed 13 years ago by danheberden

Duplicate of #8720.

Note: See TracTickets for help on using tickets.