Skip to main content

Bug Tracker

Side navigation

#7839 closed bug (duplicate)

Opened December 24, 2010 10:17AM UTC

Closed December 24, 2010 06:32PM UTC

Last modified December 30, 2010 09:35AM UTC

.closest() returns duplicates, .parents() does not

Reported by: sdyson Owned by:
Priority: undecided Milestone: 1.6
Component: unfiled Version: 1.4.4
Keywords: Cc:
Blocked by: Blocking:
Description

The following query:

$('td').parents('table')

will return a unique list of all tables on the page, no matter how many cells each table contains.

The following query:

$('td').closest('table')

will return a list of each cell's table. Each table will be duplicated in the list according to how many cells it has. For example a table with 10 cells will appear in the list 10 times.

It would seem that parents has the more sensible behaviour and that closest should mirror it.

Attachments (0)
Change History (3)

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

resolution: → duplicate
status: newclosed

Thanks for taking the time to help out the jQuery project by filing a ticket! We require that all bugs have a test case on jsFiddle in order for us to confirm and work with the behaviour you're experiencing. Please make sure to test against the latest GIT 0 version as well.

Also...are you sure you tested this against 1.4.4? I actually discovered this bug 6 months ago, and filed a pull request and the fix was landed for jQuery 1.4.3. I just made a fiddle showing that the bug is indeed fixed in 1.4.4: http://jsfiddle.net/c8MRL/ So I am going to close this as a dupe of the original, now-fixed issue.

If you have a test that demonstrates this behaviour still exists in the latest jQuery, please do share it with us! Thanks again!

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

Duplicate of #6700.

Changed December 30, 2010 09:35AM UTC by sdyson comment:3

Apologies - I was indeed using JQuery 1.4.2. Thanks for investigating the issue.