},
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() {
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];