wip: context transformation - return original context instance during first run
authorAleksander Łukasz <aleksander.lukasz@nowoczesnapolska.org.pl>
Fri, 6 Dec 2013 11:44:00 +0000 (12:44 +0100)
committerAleksander Łukasz <aleksander.lukasz@nowoczesnapolska.org.pl>
Sun, 15 Dec 2013 21:32:48 +0000 (22:32 +0100)
src/smartxml/transformations.js

index eaa292c..a5a84df 100644 (file)
@@ -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;
+
+                    }
                 }
             });
         }