smartxml: fix - DocumentNode.getIndex() now handles node being out of document tree
authorAleksander Łukasz <aleksander.lukasz@nowoczesnapolska.org.pl>
Fri, 6 Dec 2013 13:52:02 +0000 (14:52 +0100)
committerAleksander Łukasz <aleksander.lukasz@nowoczesnapolska.org.pl>
Sun, 15 Dec 2013 21:32:48 +0000 (22:32 +0100)
src/smartxml/smartxml.js

index 60ed6a0..6f12667 100644 (file)
@@ -48,6 +48,10 @@ $.extend(DocumentNode.prototype, {
     },
 
     getPath: function(ancestor) {
     },
 
     getPath: function(ancestor) {
+        if(!(this.document.containsNode(this))) {
+            return null;
+        }
+        
         var nodePath = [this].concat(this.parents()),
             toret, idx;
         ancestor = ancestor || this.document.root;
         var nodePath = [this].concat(this.parents()),
             toret, idx;
         ancestor = ancestor || this.document.root;