From 45efe54da8145f97b9ee0463e686103280e3c8b1 Mon Sep 17 00:00:00 2001 From: Niklas von Hertzen Date: Thu, 15 Jul 2021 17:08:43 +0800 Subject: [PATCH] fix: this.canvas.ownerDocument is undefined (#2590) --- src/render/canvas/canvas-renderer.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/render/canvas/canvas-renderer.ts b/src/render/canvas/canvas-renderer.ts index c9c44d4..fb4d1ab 100644 --- a/src/render/canvas/canvas-renderer.ts +++ b/src/render/canvas/canvas-renderer.ts @@ -552,7 +552,8 @@ export class CanvasRenderer { return image; } - const canvas = (this.canvas.ownerDocument as Document).createElement('canvas'); + const ownerDocument = this.canvas.ownerDocument ?? document; + const canvas = ownerDocument.createElement('canvas'); canvas.width = Math.max(1, width); canvas.height = Math.max(1, height); const ctx = canvas.getContext('2d') as CanvasRenderingContext2D;