mirror of
https://github.com/tenrok/bootstrap.git
synced 2026-06-17 19:21:23 +03:00
Fix delegation events
This commit is contained in:
@@ -115,7 +115,8 @@ const EventHandler = {
|
|||||||
return
|
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')
|
// allow to get the native events from namespaced events ('click.bs.button' --> 'click')
|
||||||
let typeEvent = originalTypeEvent.replace(stripNameRegex, '')
|
let typeEvent = originalTypeEvent.replace(stripNameRegex, '')
|
||||||
const isNative = nativeEvents.indexOf(typeEvent) > -1
|
const isNative = nativeEvents.indexOf(typeEvent) > -1
|
||||||
@@ -124,14 +125,14 @@ const EventHandler = {
|
|||||||
}
|
}
|
||||||
const events = getEvent(element)
|
const events = getEvent(element)
|
||||||
const handlers = events[typeEvent] || (events[typeEvent] = {})
|
const handlers = events[typeEvent] || (events[typeEvent] = {})
|
||||||
const uid = getUidEvent(handler, originalTypeEvent.replace(namespaceRegex, ''))
|
const uid = getUidEvent(originalHandler, originalTypeEvent.replace(namespaceRegex, ''))
|
||||||
if (handlers[uid]) {
|
if (handlers[uid]) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const fn = !delegation ? bootstrapHandler(element, handler) : bootstrapDelegationHandler(handler, delegationFn)
|
const fn = !delegation ? bootstrapHandler(element, handler) : bootstrapDelegationHandler(handler, delegationFn)
|
||||||
handlers[uid] = fn
|
handlers[uid] = fn
|
||||||
handler.uidEvent = uid
|
originalHandler.uidEvent = uid
|
||||||
element.addEventListener(typeEvent, fn, false)
|
element.addEventListener(typeEvent, fn, false)
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user