Side navigation
#10449 closed enhancement (fixed)
Opened October 07, 2011 08:57AM UTC
Closed October 08, 2011 02:13AM UTC
Last modified March 08, 2012 04:34PM UTC
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.
Attachments (0)
Change History (6)
Changed October 07, 2011 09:19AM UTC by comment:1
Changed October 07, 2011 01:18PM UTC by comment:2
component: | unfiled → traversing |
---|---|
keywords: | → needsdocs |
milestone: | None → 1.7 |
owner: | → 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.
Changed October 07, 2011 01:28PM UTC by comment:3
Docs seem pretty clear to me if one keeps reading.
Changed October 07, 2011 01:43PM UTC by comment:4
@timmywil, I agree - but the slug is still a touch on the unclear side
Changed October 08, 2011 02:13AM UTC by comment:5
keywords: | needsdocs |
---|
I've updated the docs.
Changed October 08, 2011 02:13AM UTC by comment:6
resolution: | → fixed |
---|---|
status: | assigned → closed |
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?