Bug Tracker

Modify

Ticket #6723 (closed bug: duplicate)

Opened 3 years ago

Last modified 2 years ago

:has fails in combination with :gt

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

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

comment:1 Changed 3 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 3 years ago by rwaldron

  • Priority set to low
  • Status changed from new to open
  • Version changed from 1.4.2 to 1.4.4rc
  • Milestone 1.4.3 deleted

comment:3 Changed 2 years ago by danheberden

  • Milestone set to 1.next

comment:4 Changed 2 years ago by danheberden

  • Status changed from open to closed
  • Resolution set to duplicate

comment:5 Changed 2 years ago by danheberden

Duplicate of #8720.

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.