Side navigation
#6700 closed bug (fixed)
Opened June 21, 2010 05:15PM UTC
Closed September 27, 2010 07:46PM UTC
Last modified December 24, 2010 06:32PM UTC
.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
Attachments (0)
Change History (5)
Changed June 21, 2010 06:21PM UTC by comment:1
Changed August 04, 2010 02:41AM UTC by comment:2
need: | Review → Commit |
---|
Changed August 09, 2010 01:24AM UTC by comment:3
See also #6384; should Sizzle remove dups or should jQuery remove them where they can occur?
Changed September 27, 2010 07:46PM UTC by comment:4
priority: | → undecided |
---|---|
resolution: | → fixed |
status: | new → closed |
I created a fix and did a pull request. http://github.com/ajpiano/jquery/commit/a2bd8a53f3a750606abea9bbb6ee2302437d42f3