Skip to content

Commit 0b45ac0

Browse files
committed
fix: check if the document global exists before usage
1 parent 126790b commit 0b45ac0

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/core/utils.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,10 @@ export function deepIncludes(a: any, b: any): boolean {
9090
}
9191

9292
export function isDocumentVisible(): boolean {
93-
const visibilityState = document?.visibilityState as any
94-
95-
return [undefined, 'visible', 'prerender'].includes(visibilityState)
93+
if (typeof document === 'undefined') {
94+
return true
95+
}
96+
return [undefined, 'visible', 'prerender'].includes(document.visibilityState)
9697
}
9798

9899
export function isOnline(): boolean {

0 commit comments

Comments
 (0)