From 0fac4e30a7e7e0cfe2f25a7f8dffbbfcccf8383c Mon Sep 17 00:00:00 2001 From: =?utf8?q?Aleksander=20=C5=81ukasz?= Date: Fri, 6 Dec 2013 12:44:00 +0100 Subject: [PATCH] wip: context transformation - return original context instance during first run --- src/smartxml/transformations.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/smartxml/transformations.js b/src/smartxml/transformations.js index eaa292c..a5a84df 100644 --- a/src/smartxml/transformations.js +++ b/src/smartxml/transformations.js @@ -84,14 +84,21 @@ toret.createContextTransformation = function(desc, name) { if(document === object) { this.context = document; } else { - var contextPath = object.getPath(); + var contextPath = object.getPath(), + transformation = this; Object.defineProperty(this, 'context', { get: function() { // todo: to jakos inaczej, bo np. this.context w undo transformacji before to juz nie ten sam obiekt // moze transformacja powinna zwracac zmodyfikowana sciezke do obiektu po dzialaniu run? - // tu tez trick z hasRun - return document.getNodeByPath(contextPath); + if(transformation.hasRun) { + //console.log('returning via path'); + return transformation.document.getNodeByPath(contextPath); + } else { + //console.log('returning original arg'); + return object; + + } } }); } -- 2.20.1