Bug 1021023 - Fix 'document is null' error in CssLogic_findCssSelector when inspecting <window> in XUL document. r=pbrosset

This commit is contained in:
Brian Grinstead 2014-06-05 08:40:00 -04:00
parent 58dd429b3d
commit c065592bb5

View File

@ -917,10 +917,13 @@ CssLogic.findCssSelector = function CssLogic_findCssSelector(ele) {
}
}
// So we can be unique w.r.t. our parent, and use recursion
index = positionInNodeList(ele, ele.parentNode.children) + 1;
selector = CssLogic_findCssSelector(ele.parentNode) + ' > ' +
tagName + ':nth-child(' + index + ')';
// Not unique enough yet. As long as it's not a child of the document,
// continue recursing up until it is unique enough.
if (ele.parentNode !== document) {
index = positionInNodeList(ele, ele.parentNode.children) + 1;
selector = CssLogic_findCssSelector(ele.parentNode) + ' > ' +
tagName + ':nth-child(' + index + ')';
}
return selector;
};