@claspo/document-connector 16.4.5-aria.f0 → 16.4.5-aria.f1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- const FOCUSABLE_SELECTOR='a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])';export default function trapFocus(e){const t=t=>{if("Tab"!==t.key)return;const n=e.querySelectorAll(FOCUSABLE_SELECTOR);if(console.log("el",n),0===n.length)return;const o=n[0],l=n[n.length-1];t.shiftKey?document.activeElement!==o&&document.activeElement!==e||(t.preventDefault(),l.focus()):document.activeElement===l&&(t.preventDefault(),o.focus())};return e.addEventListener("keydown",t),()=>e.removeEventListener("keydown",t)}
1
+ const FOCUSABLE_SELECTOR='a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])';function getDeepActiveElement(){let e=document.activeElement;for(;e&&e.shadowRoot&&e.shadowRoot.activeElement;)e=e.shadowRoot.activeElement;return e}function collectFocusableElements(e,t){e instanceof HTMLElement&&e.shadowRoot&&collectFocusableElements(e.shadowRoot,t);const o=e instanceof HTMLElement&&e.shadowRoot?e.shadowRoot.children:e.childNodes;for(let e=0;e<o.length;e++){const n=o[e];n instanceof HTMLElement&&(n.matches(FOCUSABLE_SELECTOR)&&t.push(n),n.shadowRoot?collectFocusableElements(n.shadowRoot,t):collectFocusableElements(n,t))}}export default function trapFocus(e){const t=t=>{if("Tab"!==t.key)return;const o=[];if(collectFocusableElements(e,o),0===o.length)return;const n=o[0],l=o[o.length-1],s=getDeepActiveElement();t.shiftKey?s!==n&&s!==e||(t.preventDefault(),l.focus()):s===l&&(t.preventDefault(),n.focus())};return e.addEventListener("keydown",t),()=>e.removeEventListener("keydown",t)}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@claspo/document-connector",
3
- "version": "16.4.5-aria.f0",
3
+ "version": "16.4.5-aria.f1",
4
4
  "scripts": {
5
5
  "test": "jest --no-cache --coverage",
6
6
  "build": "rm -rf out && tsc --project tsconfig.json && npm run minify",