From 90e1cf8f5e7eb78334a5392e6788f9e1eb2440b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrg=20Lehni?= Date: Sat, 30 Jan 2016 16:51:43 +0100 Subject: [PATCH] Canvas: Throw an error if a canvas cannot provide a 2D context. --- src/canvas/CanvasProvider.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/canvas/CanvasProvider.js b/src/canvas/CanvasProvider.js index e5505cf2..715899aa 100644 --- a/src/canvas/CanvasProvider.js +++ b/src/canvas/CanvasProvider.js @@ -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) {