Skip to content

Commit 2bddaad

Browse files
Panturaanttipalola
andauthored
Throw sensible error on for empty canvas (#3150)
Co-authored-by: Antti Palola <[email protected]>
1 parent 5e80a3f commit 2bddaad

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

src/modules/addimage.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -381,6 +381,14 @@ import { atob, btoa } from "../libs/AtobBtoa.js";
381381
}
382382

383383
if (element.nodeName === "CANVAS") {
384+
if (element.width === 0 || element.height === 0) {
385+
throw new Error(
386+
"Given canvas must have data. Canvas width: " +
387+
element.width +
388+
", height: " +
389+
element.height
390+
);
391+
}
384392
var mimeType;
385393
switch (format) {
386394
case "PNG":

test/specs/addimage.spec.js

Lines changed: 13 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)