From b64e44d1af2dcf2ea441246e00df82859493d005 Mon Sep 17 00:00:00 2001 From: Jeremy Ruston Date: Wed, 7 Mar 2012 17:42:10 +0000 Subject: [PATCH] Refactored macro implementation Now setting event handlers to the macro object, the browser invokes the handleEvent method. Gets rid of a closure, which is good --- js/Renderer.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/js/Renderer.js b/js/Renderer.js index 6ad8e9ddf..b3b23d407 100644 --- a/js/Renderer.js +++ b/js/Renderer.js @@ -210,12 +210,9 @@ MacroNode.prototype.renderInDom = function(domNode,insertBefore) { // Add some debugging information to it macroContainer.setAttribute("data-tw-macro",this.macroName); // Add event handlers to the node - var self = this, - dispatchMacroEvent = function(event) { - self.macro.events[event.type].call(self,event); - }; for(var e in this.macro.events) { - macroContainer.addEventListener(e,dispatchMacroEvent,false); + // Register this macro node to handle the event via the handleEvent() method + macroContainer.addEventListener(e,this,false); } // Render the content of the macro for(var t=0; t