Bug 1078374 - Return empty string in getPath/Selector methods for nodes outside document;r=bgrins

MozReview-Commit-ID: 5hxtjz23vXh
This commit is contained in:
Julian Descottes
2018-06-23 08:29:16 +02:00
parent 11026c5044
commit 5661629b9a
5 changed files with 15 additions and 57 deletions

View File

@@ -378,7 +378,8 @@ function getCssPath(ele) {
ele = getRootBindingParent(ele);
const document = ele.ownerDocument;
if (!document || !document.contains(ele)) {
throw new Error("getCssPath received element not inside document");
// getCssPath received element not inside document.
return "";
}
const getElementSelector = element => {
@@ -427,7 +428,8 @@ function getXPath(ele) {
ele = getRootBindingParent(ele);
const document = ele.ownerDocument;
if (!document || !document.contains(ele)) {
throw new Error("getXPath received element not inside document");
// getXPath received element not inside document.
return "";
}
// Create a short XPath for elements with IDs.