WICG / inert

Polyfill for the inert attribute and property.
Other
922 stars 79 forks source link

Fixes #144. Return early in SSR environments. #152

Closed robdodson closed 4 years ago

robdodson commented 4 years ago

Wraps the polyfill in an iife that first checks to see if window is defined before proceeding.

robdodson commented 4 years ago

Tests actually seem to be passing ok, it's just sauce labs failing to connect to Edge or Safari properly. Might be time to consider dropping Sauce in favor of GH Actions.

Js-Brecht commented 4 years ago

@robdodson FWIW, your changes look like they will fix the issue in SSR.

I believe the original issue that drew me here was that somebody was trying to use nuka-carousel in Gatsby, and it was failing. Perhaps when I have some spare time, I will try to recreate the issue, and make sure your changes fix it. I can't guarantee when that will happen though; I've got a lot going on.

Maybe it would be worth it to use renderToString() from react-dom/server in a unit test, to see if it fails in SSR? Matter of fact, it should be the same thing if you just did a require() directly from node... that's basically what's going to happen with this particular package in renderToString() anyway.

alenkas commented 4 years ago

Seems to work in my environment. No more 'Element is not defined' error.