smartxml: handle node being a root in DocumentNode.getIndex
[fnpeditor.git] / src / smartxml / smartxml.js
index b150cde..e484070 100644 (file)
@@ -136,6 +136,9 @@ $.extend(DocumentNode.prototype, {
     },
 
     getIndex: function() {
+        if(this.isRoot()) {
+            return 0;
+        }
         return this.parent().indexOf(this);
     }
 });
@@ -255,6 +258,7 @@ $.extend(ElementNode.prototype, {
             myContents = this.contents(),
             myIdx = parent.indexOf(this);
 
+
         if(myContents.length === 0) {
             return this.detach();
         }