aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohann-S <[email protected]>2017-09-01 11:17:49 +0200
committerXhmikosR <[email protected]>2019-02-20 22:05:45 +0200
commit47242cd0fea278001dda666f9aafd5d8bcb3513a (patch)
tree2a5aca84f604b1bea6b35984a5a8201155a1dcf5
parent7d7873b6f206fbbb29dbeee42a7ff94a9e1f5204 (diff)
downloadbootstrap-47242cd0fea278001dda666f9aafd5d8bcb3513a.tar.xz
bootstrap-47242cd0fea278001dda666f9aafd5d8bcb3513a.zip
Fix delegation events
-rw-r--r--js/src/dom/eventHandler.js7
1 files changed, 4 insertions, 3 deletions
diff --git a/js/src/dom/eventHandler.js b/js/src/dom/eventHandler.js
index 1348dc96e..f720f1441 100644
--- a/js/src/dom/eventHandler.js
+++ b/js/src/dom/eventHandler.js
@@ -115,7 +115,8 @@ const EventHandler = {
return
}
- const delegation = typeof handler === 'string'
+ const delegation = typeof handler === 'string'
+ const originalHandler = delegation ? delegationFn : handler
// allow to get the native events from namespaced events ('click.bs.button' --> 'click')
let typeEvent = originalTypeEvent.replace(stripNameRegex, '')
const isNative = nativeEvents.indexOf(typeEvent) > -1
@@ -124,14 +125,14 @@ const EventHandler = {
}
const events = getEvent(element)
const handlers = events[typeEvent] || (events[typeEvent] = {})
- const uid = getUidEvent(handler, originalTypeEvent.replace(namespaceRegex, ''))
+ const uid = getUidEvent(originalHandler, originalTypeEvent.replace(namespaceRegex, ''))
if (handlers[uid]) {
return
}
const fn = !delegation ? bootstrapHandler(element, handler) : bootstrapDelegationHandler(handler, delegationFn)
handlers[uid] = fn
- handler.uidEvent = uid
+ originalHandler.uidEvent = uid
element.addEventListener(typeEvent, fn, false)
},