Skip to content

Commit

Permalink
Add null check for 2d context in CanvasView
Browse files Browse the repository at this point in the history
  • Loading branch information
dobesv committed Oct 2, 2020
1 parent ee6ed9f commit 0bc1f56
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/view/CanvasView.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ var CanvasView = View.extend(/** @lends CanvasView# */{
canvas = CanvasProvider.getCanvas(size);
}
var ctx = this._context = canvas.getContext('2d');
if (!ctx) {
throw new Error('Canvas ' + canvas +
' is unable to provide a 2D context.');
}
// Save context right away, and restore in #remove(). Also restore() and
// save() again in _setElementSize() to prevent accumulation of scaling.
ctx.save();
Expand Down

0 comments on commit 0bc1f56

Please sign in to comment.