From f56efd64719cf780163c914f1e690704e6ae0482 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrg=20Lehni?= Date: Tue, 13 May 2014 12:33:39 +0200 Subject: [PATCH] Fix exceptions in ProxyContext when drawing bitmaps. --- src/canvas/ProxyContext.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/canvas/ProxyContext.js b/src/canvas/ProxyContext.js index eeff034d..965039b8 100644 --- a/src/canvas/ProxyContext.js +++ b/src/canvas/ProxyContext.js @@ -59,6 +59,15 @@ var ProxyContext = new function() { return str; } }; + + function stringify(value) { + try { + return JSON.stringify(value); + } catch (e) { + return value + ''; + } + } + Base.each(descriptions, function(description) { var match = description.match(/^([^(]+)(\()*/), name = match[1], @@ -69,7 +78,7 @@ var ProxyContext = new function() { this._indents--; console.log(this.getIndentation() + 'ctx.' + name + '(' + Array.prototype.slice.call(arguments, 0) - .map(JSON.stringify).join(', ') + .map(stringify).join(', ') + ');'); if (name === 'save') this._indents++; @@ -83,7 +92,7 @@ var ProxyContext = new function() { set: function(value) { console.log(this.getIndentation() + 'ctx.' + name + ' = ' - + JSON.stringify(value) + ';'); + + stringify(value) + ';'); return this._ctx[name] = value; } };