WICG / inert

Polyfill for the inert attribute and property.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

`Element is not defined` in deno

nnmrts opened this issue · comments

When using this library within deno inside a React SSR environment, the check introduced in #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.