Skip to main content

Bug Tracker

Side navigation

#6322 closed bug (duplicate)

Opened March 19, 2010 03:58PM UTC

Closed November 19, 2010 10:59AM UTC

Last modified November 19, 2010 10:59AM UTC

: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:
Blocked by: Blocking:

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 (1)
Change History (6)

Changed March 19, 2010 04:14PM UTC by dwt comment:1

jsbin as per ajpianos request

Changed March 19, 2010 04:39PM UTC by ajpiano comment:2

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.

Changed March 21, 2010 12:09AM UTC by dmethvin comment:3

component: unfiledselector

Changed November 12, 2010 02:40AM UTC by snover comment:4

milestone: 1.4.3

Resetting milestone to future.

Changed November 19, 2010 10:59AM UTC by snover comment:5

priority: → undecided
resolution: → duplicate
status: newclosed

Changed November 19, 2010 10:59AM UTC by snover comment:6

Duplicate of #5482.