Skip to main content

Bug Tracker

Side navigation

#4391 closed bug (invalid)

Opened March 19, 2009 11:01PM UTC

Closed March 21, 2009 01:32AM UTC

: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:
Blocked by: Blocking:
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 (1)
Change History (1)

Changed March 21, 2009 01:32AM UTC by dmethvin comment:1

resolution: → invalid
status: newclosed

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.