Bug Tracker

Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#7839 closed bug (duplicate)

.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.

Change History (3)

comment:1 Changed 9 years ago by ajpiano

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!

comment:2 Changed 9 years ago by ajpiano

Duplicate of #6700.

comment:3 Changed 9 years ago by sdyson

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

Note: See TracTickets for help on using tickets.