Ticket #6322 (closed bug: duplicate)
:has() does not correctly select elements if multiple criteria are inside
| Reported by: | dwt | Owned by: | |
|---|---|---|---|
| Priority: | undecided | Milestone: | |
| Component: | selector | Version: | 1.4.2 |
| Keywords: | Cc: | ||
| Blocking: | Blocked by: |
Description
This testcase returns false, true true
var hasFoundwithClass = 1 === $('#contingent tbody tr:has(.name:contains("foo"))').length;
var hasFoundWithoutClass = 1 === $('#contingent tbody tr:has(:contains("foo"))').length;
var hasFoundWithOnlyClass = 1 === $('#contingent tbody tr:has(.name)').length;
While I believe that all three selectors should select the same node.
Testcase attached.
Attachments
Change History
comment:1 Changed 3 years ago by dwt
jsbin as per ajpianos request http://jsbin.com/atogo3/edit
comment:2 Changed 3 years ago by ajpiano
This appears to be more complex than simply being an issue with multiple selections inside of :has()
The strangest manifestation of this issue is that with the provided markup, $("tr:has(:contains(foo).name)") returns 1 element, while $("tr:has(.name:contains(foo))") returns 0 elems.
In the case of the initial selection, jQuery never even enters the pseudoselector code that handles :contains.
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

