From: Aleksander Ɓukasz Date: Tue, 19 Nov 2013 14:28:14 +0000 (+0100) Subject: smartxml: handle node being a root in DocumentNode.getIndex X-Git-Url: https://git.mdrn.pl/fnpeditor.git/commitdiff_plain/59b807cd7a781fad54e66f1e59b09369d91d53b4 smartxml: handle node being a root in DocumentNode.getIndex --- diff --git a/src/smartxml/smartxml.js b/src/smartxml/smartxml.js index b150cde..e484070 100644 --- a/src/smartxml/smartxml.js +++ b/src/smartxml/smartxml.js @@ -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(); }