From 0683f448096c08cf47dd26136b6fcf1bff4a4001 Mon Sep 17 00:00:00 2001 From: yandeu <20306025+yandeu@users.noreply.github.com> Date: Tue, 18 Jul 2023 17:29:59 +0200 Subject: [PATCH] Detect jsdom --- src/helpers.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/helpers.ts b/src/helpers.ts index 9117ee7..cf18722 100644 --- a/src/helpers.ts +++ b/src/helpers.ts @@ -13,7 +13,9 @@ export const detectSSR = (): boolean => { // @ts-ignore const isDeno = typeof Deno !== 'undefined' const hasWindow = typeof window !== 'undefined' ? true : false - return (typeof _nano !== 'undefined' && _nano.isSSR) || isDeno || !hasWindow + const isNodejs = navigator.userAgent.includes('Node.js') || window.name == 'nodejs' + const iJsdom = navigator.userAgent.includes('jsdom') + return (typeof _nano !== 'undefined' && _nano.isSSR) || isDeno || !hasWindow || isNodejs || iJsdom } function isDescendant(desc: ParentNode | null, root: Node): boolean {