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

Closed
addyosmani opened this Issue Apr 19, 2012 · 1 comment

Comments

Projects
None yet
2 participants
@addyosmani
Member

addyosmani commented Apr 19, 2012

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

This comment has been minimized.

Show comment
Hide comment
@brandwaffle

brandwaffle Feb 6, 2013

Contributor

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/

Contributor

brandwaffle commented Feb 6, 2013

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/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment