wip: transformations - handle dictionary arguments when creating automatic proxies
authorAleksander Łukasz <aleksander.lukasz@nowoczesnapolska.org.pl>
Fri, 6 Dec 2013 15:33:42 +0000 (16:33 +0100)
committerAleksander Łukasz <aleksander.lukasz@nowoczesnapolska.org.pl>
Sun, 15 Dec 2013 21:32:48 +0000 (22:32 +0100)
src/smartxml/transformations.js

index a78c9c9..f0b89f1 100644 (file)
@@ -42,18 +42,40 @@ toret.createGenericTransformation = function(desc, name) {
         // });
 
         // potem spr na dotychczasowych undo/redo tests;
         // });
 
         // potem spr na dotychczasowych undo/redo tests;
+        
+
         this.args.forEach(function(arg, idx, args) {
         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;
+                                    }
+                                }
+                            });   
+                        }
+                    });
+                }
             }
         });
 
             }
         });