Canvas: Throw an error if a canvas cannot provide a 2D context.

This commit is contained in:
Jürg Lehni 2016-01-30 16:51:43 +01:00
parent 8c60931200
commit 90e1cf8f5e

View file

@ -29,6 +29,10 @@ var CanvasProvider = {
clear = false; // It's already cleared through createElement().
}
var ctx = canvas.getContext('2d');
if (!ctx) {
throw new Error('Canvas ' + canvas +
' is unable toprovide a 2D context.');
}
// If they are not the same size, we don't need to clear them
// using clearRect and visa versa.
if (canvas.width === width && canvas.height === height) {