From 8576bf9b76b53289b44abcb332c09ad1120267c6 Mon Sep 17 00:00:00 2001 From: Tj Holowaychuk Date: Fri, 19 Nov 2010 12:15:39 -0800 Subject: [PATCH] Fixed Canvas#getContext(), caching the CanvasRenderingContext --- lib/canvas.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/canvas.js b/lib/canvas.js index cc2f659..adcb393 100644 --- a/lib/canvas.js +++ b/lib/canvas.js @@ -84,7 +84,7 @@ Canvas.prototype.inspect = function(){ Canvas.prototype.getContext = function(contextId){ if ('2d' == contextId) { - var ctx = new Context2d(this); + var ctx = this._context2d || (this._context2d = new Context2d(this)); this.context = ctx; ctx.canvas = this; return ctx;