WICG / inert

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

`Element is not defined` in deno #178

Closed nnmrts closed 2 years ago

nnmrts commented 2 years ago

When using this library within deno inside a React SSR environment, the check introduced in https://github.com/WICG/inert/pull/152 is not enough.

In deno, window is defined and represents the usual globalThis (but document isn't for example), so this "browser check" doesn't work here. Fortunately in this case, the thing this check really should do is to check for window.Element and not just window.

My suggestion would be to replace this:

if (typeof window === 'undefined') {
    return;
}

with this:

if (typeof Element === 'undefined') {
    return;
}

and I will add a PR for that.