Ticket #4391 (closed bug: invalid)
:has() selector is inconsistent when used with element created by .after()
| Reported by: | beaugunderson | Owned by: | john |
|---|---|---|---|
| Priority: | major | Milestone: | 1.4 |
| Component: | selector | Version: | 1.3.2 |
| Keywords: | Cc: | ||
| Blocking: | Blocked by: |
Description
Attached is a reproduction that shows the problem in Chrome, IE7, and FF 3.1b3 in my testing.
The reproduction involves adding a list item containing an anchor to the page and then using .next("has:(a)") from a previous sibling to select that element.
It seems to work when .next() is used on the same node that .after() was, but not in the case where .next() is used several siblings before the node that .after() was used on. In that case, the element is not selected.
If this is expected behavior when using .after() to add nodes to the page then I think this is still a valid bug, but in that case only a documentation bug. :)
Attachments
Change History
Changed 4 years ago by beaugunderson
-
attachment
Has Selector Test.html
added
comment:1 Changed 4 years ago by dmethvin
- Status changed from new to closed
- Resolution set to invalid
The docs seem pretty clear to me already:
next only returns the very next sibling for each element, not all next siblings (see nextAll). You may provide an optional expression to filter the returned set.
http://docs.jquery.com/Traversing/next#expr
As the docs say, the optional expression is only filtering the result set. I am thinking you were expecting it to search for the next sibling element that matched the expression you provided, but that's not what it's documented to do.
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

Bug repreoduction