construct-style-sheets
construct-style-sheets copied to clipboard
Error when using it in JSDom in case `document` is undefined
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: https://github.com/calebdwilliams/construct-style-sheets/blob/bdd71c7f480ce08214e01d9cd2c215dcdf8a9097/src/Location.ts#L219
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.