Skip to main content

Bug Tracker

Side navigation

#8036 closed bug (invalid)

Opened January 22, 2011 03:29AM UTC

Closed January 24, 2011 05:10PM UTC

.closest(selectorArray) returns duplicates

Reported by: dmethvin Owned by: dmethvin
Priority: blocker Milestone: 1.5
Component: traversing Version: git
Keywords: Cc:
Blocked by: Blocking:
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/

Attachments (0)
Change History (4)

Changed January 22, 2011 03:31AM UTC by dmethvin comment:1

blocking: → 7340
component: unfiledtraversing
milestone: 1.next1.5
owner: → dmethvin
priority: undecidedblocker
status: newassigned

Changed January 22, 2011 04:02AM UTC by dmethvin comment:2

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.

Changed January 24, 2011 04:36PM UTC by john comment:3

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.

Changed January 24, 2011 05:10PM UTC by john comment:4

resolution: → invalid
status: assignedclosed

Not an issue, expected behavior.