From: Aleksander Ɓukasz Date: Fri, 6 Dec 2013 15:33:42 +0000 (+0100) Subject: wip: transformations - handle dictionary arguments when creating automatic proxies X-Git-Url: https://git.mdrn.pl/fnpeditor.git/commitdiff_plain/7e4209de3c2972b1ca4ada5e3de85197365f58af?ds=sidebyside wip: transformations - handle dictionary arguments when creating automatic proxies --- diff --git a/src/smartxml/transformations.js b/src/smartxml/transformations.js index a78c9c9..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 && arg.nodeType) { // ~ - var path = arg.getPath(); - Object.defineProperty(args, idx, { - get: function() { - if(transformation.hasRun && path) { - 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; + } + } + }); + } + }); + } } });