UNPKG

@spectrum-web-components/shared

Version:

The `@spectrum-web-components/shared` package provides essential base classes, mixins, and utilities that support developing Spectrum Web Components. This package contains foundational tools for focus management, slot observation, accessibility enhancemen

3 lines (2 loc) 1.12 kB
"use strict";let s=!0;try{document.body.querySelector(":focus-visible")}catch(a){s=!1,import("focus-visible")}export const FocusVisiblePolyfillMixin=a=>{var t,n;const r=o=>{if(o.shadowRoot==null||o.hasAttribute("data-js-focus-visible"))return()=>{};if(self.applyFocusVisiblePolyfill)self.applyFocusVisiblePolyfill(o.shadowRoot),o.manageAutoFocus&&o.manageAutoFocus();else{const i=()=>{self.applyFocusVisiblePolyfill&&o.shadowRoot&&self.applyFocusVisiblePolyfill(o.shadowRoot),o.manageAutoFocus&&o.manageAutoFocus()};return self.addEventListener("focus-visible-polyfill-ready",i,{once:!0}),()=>{self.removeEventListener("focus-visible-polyfill-ready",i)}}return()=>{}},l=Symbol("endPolyfillCoordination");class c extends(n=a,t=l,n){constructor(){super(...arguments);this[t]=null}connectedCallback(){var e;(e=super.connectedCallback)==null||e.call(this),s||requestAnimationFrame(()=>{this[l]==null&&(this[l]=r(this))})}disconnectedCallback(){var e;(e=super.disconnectedCallback)==null||e.call(this),s||requestAnimationFrame(()=>{this[l]!=null&&(this[l](),this[l]=null)})}}return c}; //# sourceMappingURL=focus-visible.js.map