From 4468d51bdcf250b3688440376c2dba985124c4c5 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Aleksander=20=C5=81ukasz?= Date: Fri, 24 Jan 2014 16:39:38 +0100 Subject: [PATCH] smartxml: Fixing invalidated paths used to access transformation node arguments This ensures that wrapper around node argument sent to the transformation is using path only the first time it needs to, not every time after first run of the transformation. --- src/smartxml/transformations.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/smartxml/transformations.js b/src/smartxml/transformations.js index e239b6a..a2a9f48 100644 --- a/src/smartxml/transformations.js +++ b/src/smartxml/transformations.js @@ -51,7 +51,7 @@ toret.createGenericTransformation = function(desc, name) { }); this.document = document; - this.hasRun = false; + this.runCount = 0; if(desc.init) { desc.init.call(this); } @@ -73,7 +73,7 @@ toret.createGenericTransformation = function(desc, name) { } var argsToPass = desc.undo ? [this].concat(this.args) : this.args; var toret = desc.impl.apply(this.context, argsToPass); - this.hasRun = true; + this.runCount++; return toret; }, undo: function() { @@ -88,6 +88,7 @@ toret.createGenericTransformation = function(desc, name) { }, wrapNodeProperty: function(object, propName, value) { var transformation = this, + lastRunNumber = 0, path; value = value || object[propName]; @@ -95,11 +96,11 @@ toret.createGenericTransformation = function(desc, name) { path = value.getPath(); Object.defineProperty(object, propName, { get: function() { - if(transformation.hasRun && path) { - return transformation.document.getNodeByPath(path); - } else { - return value; + if((lastRunNumber !== transformation.runCount) && path) { + value = transformation.document.getNodeByPath(path); + lastRunNumber = transformation.runCount; } + return value; } }); } -- 2.20.1