Skip to content

Commit 695ec61

Browse files
committed
Add null check for 2d context in CanvasView
1 parent 330b7d0 commit 695ec61

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/view/CanvasView.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@ var CanvasView = View.extend(/** @lends CanvasView# */{
4343
canvas = CanvasProvider.getCanvas(size);
4444
}
4545
var ctx = this._context = canvas.getContext('2d');
46+
if (!ctx) {
47+
throw new Error('Canvas ' + canvas +
48+
' is unable to provide a 2D context.');
49+
}
4650
// Save context right away, and restore in #remove(). Also restore() and
4751
// save() again in _setElementSize() to prevent accumulation of scaling.
4852
ctx.save();

0 commit comments

Comments
 (0)