From: Aleksander Ɓukasz Date: Fri, 6 Dec 2013 11:44:00 +0000 (+0100) Subject: wip: context transformation - return original context instance during first run X-Git-Url: https://git.mdrn.pl/fnpeditor.git/commitdiff_plain/0fac4e30a7e7e0cfe2f25a7f8dffbbfcccf8383c wip: context transformation - return original context instance during first run --- 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; + + } } }); }