Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function findElementByName(d, name) {
if (treeAdapter.isTextNode(d)) return undefined;
if (d.tagName && d.tagName.toLowerCase() === name) {
return d;
}
if (!treeAdapter.getChildNodes(d)) {
return undefined;
}
for (let i = 0; i < treeAdapter.getChildNodes(d).length; i++) {
const f = treeAdapter.getChildNodes(d)[i];
const result = findElementByName(f, name);
if (result) return result;
}
return undefined;
}
function findElementByName(d, name) {
if (treeAdapter.isTextNode(d)) return undefined;
if (d.tagName && d.tagName.toLowerCase() === name) {
return d;
}
if (!treeAdapter.getChildNodes(d)) {
return undefined;
}
for (let i = 0; i < treeAdapter.getChildNodes(d).length; i++) {
const f = treeAdapter.getChildNodes(d)[i];
const result = findElementByName(f, name);
if (result) return result;
}
return undefined;
}
function findElementByName(d, name) {
if (treeAdapter.isTextNode(d)) return undefined;
if (d.tagName && d.tagName.toLowerCase() === name) {
return d;
}
if (!treeAdapter.getChildNodes(d)) {
return undefined;
}
for (let i = 0; i < treeAdapter.getChildNodes(d).length; i++) {
const f = treeAdapter.getChildNodes(d)[i];
const result = findElementByName(f, name);
if (result) return result;
}
return undefined;
}