UNPKG

@ionic/core

Version:
1 lines 631 B
const e="ion-focused",t="ion-focusable",o=["Tab","ArrowDown","Space","Escape"," ","Shift","Enter","ArrowLeft","ArrowRight","ArrowUp"];function s(s){let n=[],c=!0;function a(t){n.forEach(t=>t.classList.remove(e)),t.forEach(t=>t.classList.add(e)),n=t}s.addEventListener("keydown",e=>{(c=o.includes(e.key))||a([])});const i=()=>{c=!1,a([])};s.addEventListener("focusin",e=>{c&&e.composedPath&&a(e.composedPath().filter(e=>!!e.classList&&e.classList.contains(t)))}),s.addEventListener("focusout",()=>{s.activeElement===s.body&&a([])}),s.addEventListener("touchstart",i),s.addEventListener("mousedown",i)}export{s as startFocusVisible};