smartxml: fix - getIndex returns undefined for a node not attached to a document...
authorAleksander Łukasz <aleksander.lukasz@nowoczesnapolska.org.pl>
Mon, 30 Jun 2014 12:52:04 +0000 (14:52 +0200)
committerAleksander Łukasz <aleksander.lukasz@nowoczesnapolska.org.pl>
Mon, 30 Jun 2014 13:02:11 +0000 (15:02 +0200)
src/smartxml/smartxml.js

index 8039916..b673865 100644 (file)
@@ -162,10 +162,14 @@ $.extend(DocumentNode.prototype, {
     },
 
     getIndex: function() {
+        var parent;
+
         if(this.isRoot()) {
             return 0;
         }
-        return this.parent().indexOf(this);
+
+        parent = this.parent();
+        return parent ? parent.indexOf(this) : undefined;
     },
 
     getNearestElementNode: function() {