From 456c8ae41ff4589a9e8fcf9dd805bb43e370cac8 Mon Sep 17 00:00:00 2001 From: lin onetwo Date: Thu, 28 Mar 2024 22:57:27 +0800 Subject: [PATCH 1/4] fix: document not exist --- src/root-observer-queue/root-observer-queue.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/root-observer-queue/root-observer-queue.ts b/src/root-observer-queue/root-observer-queue.ts index 1e235fa..276dac0 100644 --- a/src/root-observer-queue/root-observer-queue.ts +++ b/src/root-observer-queue/root-observer-queue.ts @@ -2,4 +2,4 @@ import {createPausableQueue} from "../observer-queue/create-pausable-queue"; import {observeRoot} from "../observe-root/observe-root"; // Creates a pausable queue and pass document.documentElement as the initial queue payload -export const rootObserverQueue = createPausableQueue(observeRoot, document.documentElement); \ No newline at end of file +export const rootObserverQueue = createPausableQueue(observeRoot, typeof document !== 'undefined' ? document.documentElement : undefined); From 16b03e706ab86491039ea3fffb784c9c2f8658c5 Mon Sep 17 00:00:00 2001 From: lin onetwo Date: Thu, 28 Mar 2024 22:58:28 +0800 Subject: [PATCH 2/4] Update attach-shadow.ts --- src/patch/attach-shadow.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/patch/attach-shadow.ts b/src/patch/attach-shadow.ts index 72df7a8..1f9f6ca 100644 --- a/src/patch/attach-shadow.ts +++ b/src/patch/attach-shadow.ts @@ -6,7 +6,7 @@ import {isShady} from "../util/is-shady"; */ export function patchElementPrototypeAttachShadow(callback: (node: ShadowRoot) => void): void { // If Shadow DOM is not available, or if it is based on the ShadyDOM polyfill, there's nothing (or no need) to patch - if (ORIGINAL_ATTACH_SHADOW == null || isShady()) return; + if (ORIGINAL_ATTACH_SHADOW == null || isShady() || typeof Element === 'undefined') return; Element.prototype.attachShadow = function (this: Element, shadowRootInitDict: ShadowRootInit): ShadowRoot { const shadowRoot = ORIGINAL_ATTACH_SHADOW.call(this, shadowRootInitDict); From 1c0b83637ecc8d58831ab739d292e78d2cbdf75e Mon Sep 17 00:00:00 2001 From: lin onetwo Date: Thu, 28 Mar 2024 22:58:48 +0800 Subject: [PATCH 3/4] Update attach-shadow.ts --- src/original/attach-shadow.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/original/attach-shadow.ts b/src/original/attach-shadow.ts index 6d8d6bd..43dedae 100644 --- a/src/original/attach-shadow.ts +++ b/src/original/attach-shadow.ts @@ -1 +1 @@ -export const ORIGINAL_ATTACH_SHADOW = Element.prototype.attachShadow; +export const ORIGINAL_ATTACH_SHADOW = typeof Element !== 'undefined' ? Element.prototype.attachShadow : undefined; From ef1f5346ca740fd0d94463c6b3245e5c60f8d6c0 Mon Sep 17 00:00:00 2001 From: lin onetwo Date: Thu, 28 Mar 2024 22:59:44 +0800 Subject: [PATCH 4/4] Update package.json --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 8fa0aea..eb730b7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@wessberg/connection-observer", - "version": "1.0.5", + "version": "1.1.0", "description": "An API that provides a way to asynchronously observe the connectedness of a target Node or querySelector inside a document", "repository": { "type": "git",