editor: canvas - let every child of a detached element clean up after itself
[fnpeditor.git] / src / smartxml / smartxml.js
index f9f78e8..8039916 100644 (file)
@@ -17,12 +17,21 @@ var DocumentNode = function(nativeNode, document) {
         throw new Error('undefined document for a node');
     }
     this.document = document;
+    this.object = {};
     this._setNativeNode(nativeNode);
 
 };
 
 $.extend(DocumentNode.prototype, {
 
+    getProperty: function(propName) {
+        var toret = this.object[propName];
+        if(toret && _.isFunction(toret)) {
+            toret = toret.call(this);
+        }
+        return toret;
+    },
+
     transform: function(Transformation, args) {
         var transformation = new Transformation(this.document, this, args);
         return this.document.transform(transformation);
@@ -140,12 +149,9 @@ $.extend(DocumentNode.prototype, {
         var node = (metaData && metaData.node) ? metaData.node : this,
             event = new events.ChangeEvent(type, $.extend({node: node}, metaData || {}));
         if(type === 'nodeDetached' || this.document.containsNode(event.meta.node)) {
-            if(type === 'nodeMoved') {
-                event.meta.parent = origParent;
-            }
             this.document.trigger('change', event);
         }
-        if((type === 'nodeAdded' || type === 'nodeMoved') && !this.document.containsNode(this) && nodeWasContained) {
+        if(type === 'nodeAdded' && !this.document.containsNode(this) && nodeWasContained) {
              event = new events.ChangeEvent('nodeDetached', {node: node, parent: origParent});
              this.document.trigger('change', event);
         }