From c5595e5b67f24a2112afacd27d670dc2fda95f43 Mon Sep 17 00:00:00 2001 From: Johann-S Date: Sun, 3 Sep 2017 17:11:41 +0200 Subject: [PATCH] Add polyfill for focusin and focusout --- js/src/dom/eventHandler.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/js/src/dom/eventHandler.js b/js/src/dom/eventHandler.js index f720f14413..42c91c0906 100644 --- a/js/src/dom/eventHandler.js +++ b/js/src/dom/eventHandler.js @@ -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