From 96659d72990a7a46f8cffd49ef860287cc5a1b13 Mon Sep 17 00:00:00 2001 From: Jason Follas Date: Sun, 1 Apr 2012 11:00:58 -0400 Subject: [PATCH] Revert to previous no-parameter (image/png) behavior if an exception is encountered while calling canvas toDataURL() with parameters. See this forum post: http://www.kineticjs.com/forum/viewtopic.php?f=10&t=423 --- src/Stage.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/Stage.js b/src/Stage.js index ee55b8af..86ad461b 100644 --- a/src/Stage.js +++ b/src/Stage.js @@ -161,7 +161,15 @@ Kinetic.Stage.prototype = { addLayer(n); } else { - callback(bufferLayer.getCanvas().toDataURL(mimeType, quality)); + try { + // If this call fails (due to browser bug, like in Firefox 3.6), + // then revert to previous no-parameter image/png behavior + callback(bufferLayer.getCanvas().toDataURL(mimeType, quality)); + } + catch(exception) + { + callback(bufferLayer.getCanvas().toDataURL()); + } } }; imageObj.src = dataURL;