Bug Tracker

Modify

Ticket #8036 (closed bug: invalid)

Opened 2 years ago

Last modified 2 years ago

.closest(selectorArray) returns duplicates

Reported by: dmethvin Owned by: dmethvin
Priority: blocker Milestone: 1.5
Component: traversing Version: git
Keywords: Cc:
Blocking: #7340 Blocked by:

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

comment:1 Changed 2 years ago by dmethvin

  • Status changed from new to assigned
  • Component changed from unfiled to traversing
  • Priority changed from undecided to blocker
  • Milestone changed from 1.next to 1.5
  • Owner set to dmethvin
  • Blocking 7340 added

comment:2 Changed 2 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 2 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 2 years ago by john

  • Status changed from assigned to closed
  • Resolution set to invalid

Not an issue, expected behavior.

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.