#14100 closed bug (notabug)
.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 (>).
Change History (8)
comment:1 Changed 10 years ago by
Component: | unfiled → traversing |
---|---|
Milestone: | None → 1.10.3/2.0.4 |
Owner: | set to timmywil |
Priority: | undecided → high |
Status: | new → assigned |
comment:2 Changed 10 years ago by
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?
comment:3 Changed 10 years ago by
Resolution: | → notabug |
---|---|
Status: | assigned → closed |
@dmethvin:
You're right, forgive my confusion.
comment:4 Changed 10 years ago by
Now, does it make sense for these two cases to be different? Is the selector case wrong?
comment:5 Changed 10 years ago by
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.
comment:6 Changed 10 years ago by
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.
comment:7 Changed 10 years ago by
Duplicate of http://bugs.jquery.com/ticket/7205
Also kind of duplicate of http://bugs.jquery.com/ticket/8384
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.