Skip to content

Commit b353aac

Browse files
committed
Check for existence of canvas classes before instanceof check
1 parent 7f75f42 commit b353aac

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/utils/image.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,12 @@ export class RawImage {
121121
return await this.fromURL(input);
122122
} else if (input instanceof Blob) {
123123
return await this.fromBlob(input);
124-
} else if (input instanceof HTMLCanvasElement || input instanceof OffscreenCanvas) {
125-
return await this.fromCanvas(input);
124+
} else if (
125+
(typeof HTMLCanvasElement !== "undefined" && input instanceof HTMLCanvasElement)
126+
||
127+
(typeof OffscreenCanvas !== "undefined" && input instanceof OffscreenCanvas)
128+
) {
129+
return this.fromCanvas(input);
126130
} else {
127131
throw new Error(`Unsupported input type: ${typeof input}`);
128132
}

0 commit comments

Comments
 (0)