Skip to content

Commit

Permalink
event-handler.js: use a plain for loop. (twbs#28853)
Browse files Browse the repository at this point in the history
  • Loading branch information
XhmikosR authored and Johann-S committed Jun 3, 2019
1 parent 319de5b commit 8a79cf8
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions js/src/dom/event-handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,11 +136,13 @@ function bootstrapDelegationHandler(element, selector, fn) {
}

function findHandler(events, handler, delegationSelector = null) {
for (const uid of Object.keys(events)) {
const event = events[uid]
const uidEventList = Object.keys(events)

for (let i = 0, len = uidEventList.length; i < len; i++) {
const event = events[uidEventList[i]]

if (event.originalHandler === handler && event.delegationSelector === delegationSelector) {
return events[uid]
return event
}
}

Expand Down Expand Up @@ -204,7 +206,7 @@ function addHandler(element, originalTypeEvent, handler, delegationFn, oneOff) {
function removeHandler(element, events, typeEvent, handler, delegationSelector) {
const fn = findHandler(events[typeEvent], handler, delegationSelector)

if (fn === null) {
if (!fn) {
return
}

Expand Down

0 comments on commit 8a79cf8

Please sign in to comment.