X-Git-Url: https://git.mdrn.pl/fnpeditor.git/blobdiff_plain/2a63804a0f4838a7016c84735df10dde26f8bb38..90a4709555ba28d2175c7a359d538e7775f9bf64:/src/smartxml/transformations.js?ds=sidebyside diff --git a/src/smartxml/transformations.js b/src/smartxml/transformations.js index 5f0756c..f0b89f1 100644 --- a/src/smartxml/transformations.js +++ b/src/smartxml/transformations.js @@ -42,18 +42,40 @@ toret.createGenericTransformation = function(desc, name) { // }); // potem spr na dotychczasowych undo/redo tests; + + this.args.forEach(function(arg, idx, args) { - if(arg.nodeType) { // ~ - var path = arg.getPath(); - Object.defineProperty(args, idx, { - get: function() { - if(transformation.hasRun) { - return transformation.document.getNodeByPath(path); - } else { - return arg; + var path; + if(arg) { + if(arg.nodeType) { // ~ + path = arg.getPath(); + Object.defineProperty(args, idx, { + get: function() { + if(transformation.hasRun && path) { + return transformation.document.getNodeByPath(path); + } else { + return arg; + } } - } - }); + }); + } else if(_.isObject(arg)) { + _.keys(arg).forEach(function(key) { + var value = arg[key], + path; + if(value && value.nodeType) { + path = value.getPath(); + Object.defineProperty(arg, key, { + get: function() { + if(transformation.hasRun && path) { + return transformation.document.getNodeByPath(path); + } else { + return value; + } + } + }); + } + }); + } } });