throw error when checking for the index of a node that has no parent.

it probably isn't in the dom if this is the case.
Check if it's there before using this function
This commit is contained in:
ansuz 2016-02-23 15:53:58 +01:00
parent de46be85ba
commit 39f56d4fd1

View file

@ -89,6 +89,7 @@ define([], function () {
var indexOfNode = tree.indexOfNode = function (el) {
if (!(el && el.parentNode)) {
console.log("No parentNode found!");
throw new Error('No parentNode found!');
}
return Array.prototype.indexOf.call(el.parentNode.childNodes, el);
};