smartxml: fix - running custom undo was stopping node arguments refetching on redo
[fnpeditor.git] / src / smartxml / smartxml.js
index 8bf531b..9227e0f 100644 (file)
@@ -66,7 +66,7 @@ $.extend(DocumentNode.prototype, {
             }
         });
 
-        if(idx !== 'undefined') {
+        if(idx !== undefined) {
             nodePath = nodePath.slice(0, idx);
         }
         toret = nodePath.map(function(node) {return node.getIndex(); });
@@ -203,6 +203,10 @@ $.extend(ElementNode.prototype, {
         return toret;
     },
 
+    containsNode: function(node) {
+        return node && (node.nativeNode === this.nativeNode || node._$.parents().index(this._$) !== -1);
+    },
+
     toXML: function() {
         var wrapper = $('<div>');
         wrapper.append(this._getXMLDOMToDump());
@@ -354,7 +358,7 @@ $.extend(Document.prototype, Backbone.Events, {
     },
 
     containsNode: function(node) {
-        return this.root && (node.nativeNode === this.root.nativeNode || node._$.parents().index(this.root._$) !== -1);
+        return this.root && this.root.containsNode(node);
     },
 
     getSiblingParents: function(params) {
@@ -570,6 +574,12 @@ $.extend(Document.prototype, Backbone.Events, {
         }
     },
 
+    transaction: function(callback, context) {
+        this.startTransaction();
+        callback.call(context);
+        this.endTransaction();
+    },
+
     getNodeByPath: function(path) {
         var toret = this.root;
         path.forEach(function(idx) {