#10449 closed enhancement (fixed)
Function $("#id").closest(".class") returns element $("#id") itself if it has .class
Reported by: | San4es | Owned by: | kswedberg |
---|---|---|---|
Priority: | low | Milestone: | 1.7 |
Component: | traversing | Version: | 1.7b1 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
Tests were performed on following example with all popular browsers and all versions of jQuery:
<ul class="list"> <li class="item"> 1 <ul class="list"> <li id="test" class="item">2</li> </ul> </li> </ul>
(http://jsfiddle.net/QParz/1/)
When use $("#test").closest(".item") we get second list item, but it's expected first list item.
Change History (6)
comment:1 Changed 12 years ago by
comment:2 Changed 12 years ago by
Component: | unfiled → traversing |
---|---|
Keywords: | needsdocs added |
Milestone: | None → 1.7 |
Owner: | set to kswedberg |
Priority: | undecided → low |
Status: | new → assigned |
Type: | bug → enhancement |
I agree that the doc here could use a touch of refinement, but this isn't a bug - it's the way that closest has always worked since it was introduced and it is used thusly by both users and jQuery core internally for event delegation.
comment:4 Changed 12 years ago by
@timmywil, I agree - but the slug is still a touch on the unclear side
comment:6 Changed 12 years ago by
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
Note: See
TracTickets for help on using
tickets.
In other point of view, that isn't bug if you using function .closest() considering semantic meaning of "closest" word, but documentation says "Get the first ancestor element..." and so element itself is unexpected value, because element is not equal to its ancestor, is it?