fix: this.canvas.ownerDocument is undefined (#2590)

This commit is contained in:
Niklas von Hertzen 2021-07-15 17:08:43 +08:00 committed by GitHub
parent cd99f11b1b
commit 45efe54da8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -552,7 +552,8 @@ export class CanvasRenderer {
return image; 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.width = Math.max(1, width);
canvas.height = Math.max(1, height); canvas.height = Math.max(1, height);
const ctx = canvas.getContext('2d') as CanvasRenderingContext2D; const ctx = canvas.getContext('2d') as CanvasRenderingContext2D;