Permalink
Browse files

Fixed bug where send/@targetexpr was being evaluated multiple times.

  • Loading branch information...
1 parent f58c4df commit c5c899f72eddceadd33e5e868bf7ff167eeac93a @jbeard4 committed Jan 11, 2013
Showing with 7 additions and 3 deletions.
  1. +7 −3 lib/core/util/code-gen.js
@@ -117,17 +117,21 @@ var actionTags = {
},
"send" : function(action){
- var target = (pm.platform.dom.hasAttribute(action,"targetexpr") ? pm.platform.dom.getAttribute(action,"targetexpr") : JSON.stringify(pm.platform.dom.getAttribute(action,"target")));
+ var target = (pm.platform.dom.hasAttribute(action,"targetexpr") ? pm.platform.dom.getAttribute(action,"targetexpr") : JSON.stringify(pm.platform.dom.getAttribute(action,"target"))),
+ targetVariableName = '_scionTargetRef',
+ targetDeclaration = 'var ' + targetVariableName + ' = ' + target + ';\n';
+
var event = "{\n" +
- "target: " + target + ",\n" +
+ "target: " + targetVariableName + ",\n" +
"name: " + (pm.platform.dom.hasAttribute(action,"eventexpr") ? pm.platform.dom.getAttribute(action,"eventexpr") : JSON.stringify(pm.platform.dom.getAttribute(action,"event"))) + ",\n" +
"type: " + (pm.platform.dom.hasAttribute(action,"typeexpr") ? pm.platform.dom.getAttribute(action,"typeexpr") : JSON.stringify(pm.platform.dom.getAttribute(action,"type"))) + ",\n" +
"data: " + constructSendEventData(action) + ",\n" +
"origin: $origin\n" +
"}";
var send =
- "if(" + target + " === '#_internal'){\n" +
+ targetDeclaration +
+ "if(" + targetVariableName + " === '#_internal'){\n" +
"$raise(" + event + ");\n" +
"}else{\n" +
"$send(" + event + ", {\n" +

0 comments on commit c5c899f

Please sign in to comment.