Skip to content

Commit 4f882e6

Browse files
fix: prevent TypeError when globalThis.window is undefined (#1176)
Co-authored-by: Abarajithan Ramachandran <[email protected]>
1 parent 3d7005a commit 4f882e6

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/utils/dataTransfer/Clipboard.ts

+10-2
Original file line numberDiff line numberDiff line change
@@ -216,10 +216,18 @@ const g = globalThis as {
216216
}
217217
/* istanbul ignore else */
218218
if (typeof g.afterEach === 'function') {
219-
g.afterEach(() => resetClipboardStubOnView(globalThis.window))
219+
g.afterEach(() => {
220+
if (typeof globalThis.window !== 'undefined') {
221+
resetClipboardStubOnView(globalThis.window)
222+
}
223+
})
220224
}
221225

222226
/* istanbul ignore else */
223227
if (typeof g.afterAll === 'function') {
224-
g.afterAll(() => detachClipboardStubFromView(globalThis.window))
228+
g.afterAll(() => {
229+
if (typeof globalThis.window !== 'undefined') {
230+
detachClipboardStubFromView(globalThis.window)
231+
}
232+
})
225233
}

0 commit comments

Comments
 (0)