From e4d52a1ac6c7a91a37988f7b3340eea15b50ed85 Mon Sep 17 00:00:00 2001 From: Liwen Guo Date: Tue, 26 Nov 2019 05:16:07 +0100 Subject: [PATCH] Fix error in server-side rendering (#2039) --- src/index.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/index.ts b/src/index.ts index ee5e9a1..e6bc7a8 100644 --- a/src/index.ts +++ b/src/index.ts @@ -25,7 +25,9 @@ const html2canvas = (element: HTMLElement, options: Partial = {}): Prom export default html2canvas; -CacheStorage.setContext(window); +if (typeof window !== "undefined") { + CacheStorage.setContext(window); +} const renderElement = async (element: HTMLElement, opts: Partial): Promise => { const ownerDocument = element.ownerDocument;