focus-trap icon indicating copy to clipboard operation
focus-trap copied to clipboard

call define conditionally

Open patrickarlt opened this issue 6 years ago • 0 comments

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.

patrickarlt avatar Aug 06 '19 21:08 patrickarlt