Skip to content

Commit

Permalink
Throw exception for unknown canvas type instead create Image by def…
Browse files Browse the repository at this point in the history
…ault
  • Loading branch information
piranna committed Mar 21, 2020
1 parent 64fb2e5 commit 45021a7
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/Canvas.cc
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ NAN_METHOD(Canvas::New) {
else if (0 == strcmp("svg", *Nan::Utf8String(info[2])))
backend = new SvgBackend(width, height);
else
backend = new ImageBackend(width, height);
return Nan::ThrowRangeError("Unknown canvas type");
}
else
backend = new ImageBackend(width, height);
Expand Down
4 changes: 2 additions & 2 deletions test/canvas.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -260,8 +260,8 @@ describe('Canvas', function () {
assert.equal(canvas.type, 'pdf')
var canvas = createCanvas(10, 10, 'svg')
assert.equal(canvas.type, 'svg')
var canvas = createCanvas(10, 10, 'hey')
assert.equal(canvas.type, 'image')

assert.throws(function () { createCanvas(10, 10, 'hey'); }, /RangeError/);
})

it('Canvas#getContext("2d")', function () {
Expand Down

0 comments on commit 45021a7

Please sign in to comment.