Side navigation
#14100 closed bug (notabug)
Opened July 03, 2013 02:54PM UTC
Closed July 03, 2013 03:43PM UTC
Last modified September 16, 2013 01:21AM UTC
.has() method ignores child ( > ) selector
Reported by: | goozak | Owned by: | timmywil |
---|---|---|---|
Priority: | high | Milestone: | 1.11/2.1 |
Component: | traversing | Version: | 1.10.1 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
There is a difference between the .has() method and the :has() selector with regards to the child selector (>)
The .has() method seems to ignore the presence of the child selector (>).
Attachments (0)
Change History (8)
Changed July 03, 2013 03:16PM UTC by comment:1
component: | unfiled → traversing |
---|---|
milestone: | None → 1.10.3/2.0.4 |
owner: | → timmywil |
priority: | undecided → high |
status: | new → assigned |
Changed July 03, 2013 03:23PM UTC by comment:2
It seems consistent with the docs:
The supplied selector is tested against the **descendants** of the matching elements; the element will be included in the result if any of its descendant elements matches the selector. -- http://api.jquery.com/has/
One of the descendants of the outer td
has a descendant with an input
element as a child.
Also note that the selector string matching the .has()
method case would be #rec td *:has(> input)
and not the one you've used, since it's testing the descendants of the set and not the set elements themselves.
Does that make sense?
Changed July 03, 2013 03:43PM UTC by comment:3
resolution: | → notabug |
---|---|
status: | assigned → closed |
@dmethvin:
You're right, forgive my confusion.
Changed July 03, 2013 04:06PM UTC by comment:4
Now, does it make sense for these two cases to be different? Is the selector case wrong?
Changed July 03, 2013 05:20PM UTC by comment:5
I stand behind the selector behavior, and would argue that our documentation text is sufficiently vague regarding implied scope to support either method implementation, though I personally prefer it to match the selector.
At any rate, this fix can be had for 15 min+gz bytes if we come down in favor of it.
Changed July 03, 2013 05:22PM UTC by comment:6
Continuing to work as documented seems fine with me. No change required. As Dave points out, it _does_ match the selector, just depends on which selector you're talking about.
Changed July 06, 2013 03:59PM UTC by comment:7
Duplicate of http://bugs.jquery.com/ticket/7205
Also kind of duplicate of http://bugs.jquery.com/ticket/8384
Changed September 16, 2013 01:21AM UTC by comment:8
milestone: | 1.10.3/2.0.4 → 1.11/2.1 |
---|
Bulk update for new milestone
This is valid.
.has()
selects its targets then independently does a.contains()
check. However, this is probably the only use case I can think of that would fail.