Bug Tracker

Opened 9 years ago

Closed 9 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 9 years ago by dmethvin

Blocking: 7340 added
Component: unfiledtraversing
Milestone: 1.next1.5
Owner: set to dmethvin
Priority: undecidedblocker
Status: newassigned

comment:2 Changed 9 years ago by dmethvin

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.

comment:3 Changed 9 years ago by john

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 9 years ago by john

Resolution: invalid
Status: assignedclosed

Not an issue, expected behavior.

Note: See TracTickets for help on using tickets.