]> git.ipfire.org Git - thirdparty/bootstrap.git/commitdiff
Add polyfill for focusin and focusout
authorJohann-S <johann.servoire@gmail.com>
Sun, 3 Sep 2017 15:11:41 +0000 (17:11 +0200)
committerXhmikosR <xhmikosr@gmail.com>
Wed, 20 Feb 2019 20:05:45 +0000 (22:05 +0200)
js/src/dom/eventHandler.js

index f720f14413e58ed6d8015b5ea55a0f93af8e79ed..42c91c0906e481719c178fc5bfd13b04c69dcebe 100644 (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