0
0
mirror of https://github.com/twbs/bootstrap.git synced 2025-01-17 09:52:29 +01:00

Add polyfill for focusin and focusout

This commit is contained in:
Johann-S 2017-09-03 17:11:41 +02:00 committed by XhmikosR
parent aba87279fd
commit c5595e5b67

View File

@ -133,7 +133,7 @@ const EventHandler = {
const fn = !delegation ? bootstrapHandler(element, handler) : bootstrapDelegationHandler(handler, delegationFn)
handlers[uid] = fn
originalHandler.uidEvent = uid
element.addEventListener(typeEvent, fn, false)
element.addEventListener(typeEvent, fn, delegation)
},
one(element, event, handler) {
@ -193,4 +193,18 @@ const EventHandler = {
}
}
// focusin and focusout polyfill
if (typeof window.onfocusin === 'undefined') {
(() => {
function listenerFocus(event) {
EventHandler.trigger(event.target, 'focusin')
}
function listenerBlur(event) {
EventHandler.trigger(event.target, 'focusout')
}
EventHandler.on(document, 'focus', 'input', listenerFocus)
EventHandler.on(document, 'blur', 'input', listenerBlur)
})()
}
export default EventHandler