Skip to content

Loading…

.parents() orders each tier of results back-to-front #4

Closed
addyosmani opened this Issue · 1 comment

2 participants

@addyosmani
jQuery Foundation member

Not sure if this counts as a bug, but when finding parents of a collection of more than one element the resulting collection has the parents in a back-to-front order at each tier. e.g

<div class="div1"><span></span></div><div class="div2"><span></span></div>

$("span").parents() // [div2, div1, body, html]
                    // expected [div1, div2, body, html]

Test case: http://jsfiddle.net/vkGEQ/
Original ticket: http://bugs.jquery.com/ticket/11385

Team notes

This is by design , but the docs should mention it.

@brandwaffle

The bug ticket referenced above addresses the issue of the elements being returned from most closely nested to highest-level ancestor, but it doesn't mention the fact that sibling elements are returned backwards. Maybe this needs to go back in as a core bug separate from the above-referenced issue.

Also updated the fiddle example, as there was some incorrect markup (<p> tags not getting closed): http://jsfiddle.net/vkGEQ/4/

@dmethvin dmethvin closed this in c1c9fc9
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.