From: Aleksander Ɓukasz Date: Mon, 30 Jun 2014 12:52:04 +0000 (+0200) Subject: smartxml: fix - getIndex returns undefined for a node not attached to a document... X-Git-Url: https://git.mdrn.pl/fnpeditor.git/commitdiff_plain/cb448b7a76c90d02af296fca3830b056f0639a1e?ds=sidebyside;hp=a0ea5d8b3f8045f428a032df8cacde0ed54172ab smartxml: fix - getIndex returns undefined for a node not attached to a document that has no parent --- diff --git a/src/smartxml/smartxml.js b/src/smartxml/smartxml.js index 8039916..b673865 100644 --- a/src/smartxml/smartxml.js +++ b/src/smartxml/smartxml.js @@ -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() {