X-Git-Url: https://git.mdrn.pl/fnpeditor.git/blobdiff_plain/8c59ee4d6be4babb8e6a908c07576bff7e2e59f2..d0e1e19934b1c67a46a9b9c271b5054455edc5ad:/src/smartxml/smartxml.js diff --git a/src/smartxml/smartxml.js b/src/smartxml/smartxml.js index 8039916..b449d82 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() { @@ -295,7 +299,7 @@ $.extend(TextNode.prototype, { var parseXML = function(xml) { var toret = $($.trim(xml)); - if(!toret.length) { + if(toret.length !== 1) { throw new Error('Unable to parse XML: ' + xml); } return toret[0];