#6700 closed bug (fixed)
.closest() returns duplicates of the same element within the matched set.
Reported by: | ajpiano | Owned by: | |
---|---|---|---|
Priority: | undecided | Milestone: | 1.4.3 |
Component: | traversing | Version: | 1.4.2 |
Keywords: | closest unique ancestors | Cc: | |
Blocked by: | Blocking: |
Description
If, for instance, someone were to do $("#someTable tr").closest("table"), the returned set will include the same ancestor table-element once for each row in the table, which is an undesirable and unexpected result. The set should be run through jQuery.unique, if necessary, to prevent this from happening.
A simple piece of code that illustrates this issue is
$('<div><span/><span/></div>').find('span').closest('div').length === 2
Change History (5)
comment:1 Changed 13 years ago by
comment:2 Changed 13 years ago by
need: | Review → Commit |
---|
comment:3 Changed 13 years ago by
See also #6384; should Sizzle remove dups or should jQuery remove them where they can occur?
comment:4 Changed 13 years ago by
Priority: | → undecided |
---|---|
Resolution: | → fixed |
Status: | new → closed |
Note: See
TracTickets for help on using
tickets.
I created a fix and did a pull request. http://github.com/ajpiano/jquery/commit/a2bd8a53f3a750606abea9bbb6ee2302437d42f3