focus-trap
focus-trap copied to clipboard
call define conditionally
I'm working on a component library built with Stencil JS that is using focus trap and I ran into https://github.com/ionic-team/stencil/issues/1782 trying to setup prerendering with Stencil. When Stencil prerenders it loads the focus trap code and dies on the call to window.customElements.define which doesn't exist.
Fortunately it is pretty easy to avoid this by wrapping the window.customElements.define call in a check to make sure window.customElements exists first. This solves the issue with prerendering with Stencil so I decided to make a PR.