Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when using it in JSDom in case document is undefined #130

Open
leifmarcus opened this issue Sep 26, 2024 · 2 comments
Open

Error when using it in JSDom in case document is undefined #130

leifmarcus opened this issue Sep 26, 2024 · 2 comments

Comments

@leifmarcus
Copy link

Describe the bug
When using the construct-style-sheet for instance in JSDom, then in some cases, document seems to be undefined. There was an if condition introduced with a fix:

if (!document) {

This will throw an error when document is undefined: Error: Uncaught [ReferenceError: document is not defined]

To Reproduce
Steps to reproduce the behavior: Is not as easy to provide a reproduction, but the bug is clear, I guess.

Expected behavior
The error should not be thrown in non-dom-like environments.
In order to solve the problem, the if condition needs to be

// this will not throw an error when document is not defined.
if (typeof document === 'undefined') {

Additional context
So far, this problem was detected in JSDom environment when running custom components in Vitest.

@denyo
Copy link
Contributor

denyo commented Sep 26, 2024

There is this PR already: #128

@felixmagnus
Copy link

Any update on this? Would be great if the PR could be merged 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants