Skip to main content

Bug Tracker

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 ajpiano comment:1

Changed August 04, 2010 02:41AM UTC by dmethvin comment:2

need: ReviewCommit

Changed August 09, 2010 01:24AM UTC by dmethvin 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 john comment:4

priority: → undecided
resolution: → fixed
status: newclosed

Changed December 24, 2010 06:32PM UTC by ajpiano comment:5

#7839 is a duplicate of this ticket.