From 1deed94e04fe30e68e766262e2fa57a1d9cc0d65 Mon Sep 17 00:00:00 2001 From: Danny Yoo Date: Wed, 13 Jul 2011 15:13:02 -0400 Subject: [PATCH] continuing to work on the image example --- image/private/kernel.js | 10 ++++++---- js-assembler/runtime-src/baselib-ports.js | 2 ++ 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/image/private/kernel.js b/image/private/kernel.js index cce8d58..964f8d6 100644 --- a/image/private/kernel.js +++ b/image/private/kernel.js @@ -157,16 +157,18 @@ BaseImage.prototype.toDomNode = function(cache) { var height = that.getHeight(); var canvas = makeCanvas(width, height); + // KLUDGE: on IE, the canvas rendering functions depend on a // context where the canvas is attached to the DOM tree. // We initialize an afterAttach hook; the client's responsible // for calling this after the dom node is attached to the // document. - canvas.afterAttach = function() { - var ctx = canvas.getContext("2d"); - that.render(ctx, 0, 0); - }; + $(canvas).bind('afterAttach', + function(event) { + var ctx = canvas.getContext("2d"); + that.render(ctx, 0, 0); + }); return canvas; }; diff --git a/js-assembler/runtime-src/baselib-ports.js b/js-assembler/runtime-src/baselib-ports.js index b57c951..cbf98f4 100644 --- a/js-assembler/runtime-src/baselib-ports.js +++ b/js-assembler/runtime-src/baselib-ports.js @@ -16,6 +16,7 @@ StandardOutputPort.prototype = baselib.heir(OutputPort.prototype); StandardOutputPort.prototype.writeDomNode = function(MACHINE, domNode) { MACHINE.params['currentDisplayer'](MACHINE, domNode); + jQuery(domNode).trigger({type : 'afterAttach'}); }; var StandardErrorPort = function() { @@ -24,6 +25,7 @@ StandardErrorPort.prototype = baselib.heir(OutputPort.prototype); StandardErrorPort.prototype.writeDomNode = function(MACHINE, domNode) { MACHINE.params['currentErrorDisplayer'](MACHINE, domNode); + jQuery(domNode).trigger({type : 'afterAttach'}); };