From 59b807cd7a781fad54e66f1e59b09369d91d53b4 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Aleksander=20=C5=81ukasz?= Date: Tue, 19 Nov 2013 15:28:14 +0100 Subject: [PATCH] smartxml: handle node being a root in DocumentNode.getIndex --- src/smartxml/smartxml.js | 4 ++++ 1 file changed, 4 insertions(+) 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(); } -- 2.20.1