Opened 12 years ago
Closed 12 years ago
#8036 closed bug (invalid)
.closest(selectorArray) returns duplicates
Reported by: | dmethvin | Owned by: | dmethvin |
---|---|---|---|
Priority: | blocker | Milestone: | 1.5 |
Component: | traversing | Version: | git |
Keywords: | Cc: | ||
Blocked by: | Blocking: | #7340 |
Description
If an element matches more than one selector in selectorArray, it is returned once for each match. In particular, this causes event.js/liveHandler to erroneously call the same handler multiple times on the same element for a single event.
Test case: http://jsfiddle.net/dmethvin/gjrY5/
Change History (4)
comment:1 Changed 12 years ago by
Blocking: | 7340 added |
---|---|
Component: | unfiled → traversing |
Milestone: | 1.next → 1.5 |
Owner: | set to dmethvin |
Priority: | undecided → blocker |
Status: | new → assigned |
comment:2 Changed 12 years ago by
comment:3 Changed 12 years ago by
This is the expected behavior - it returns one match for each provided selector. The only way it'd be called more than once for a single event would be if pass in multiple selectors.
The de-dupe logic should definitely be external to closest in that case, if you need to remove multiple events.
comment:4 Changed 12 years ago by
Resolution: | → invalid |
---|---|
Status: | assigned → closed |
Not an issue, expected behavior.
Looking at the code some more, I wonder if the solution is to de-dup in liveHandler. We definitely don't want to call the handler twice in these cases, it was only attached once.