smartxml: fix - getIndex returns undefined for a node not attached to a document...
[fnpeditor.git] / src / smartxml / smartxml.js
index 8039916..b673865 100644 (file)
@@ -162,10 +162,14 @@ $.extend(DocumentNode.prototype, {
     },
 
     getIndex: function() {
     },
 
     getIndex: function() {
+        var parent;
+
         if(this.isRoot()) {
             return 0;
         }
         if(this.isRoot()) {
             return 0;
         }
-        return this.parent().indexOf(this);
+
+        parent = this.parent();
+        return parent ? parent.indexOf(this) : undefined;
     },
 
     getNearestElementNode: function() {
     },
 
     getNearestElementNode: function() {