Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | export function findElementByTagNameRecursively(node, tagName) { // Return if the element matches the tag name if (node.nodeName.toLowerCase() === tagName) { return node; } // Get children of root node let children = node.childNodes; if (node.shadowRoot) { children = node.shadowRoot.childNodes; } // Recursively traverse children to find element with selector for (let i = 0, len = children.length; i < len; i++) { return findElementByTagNameRecursively(children[i], tagName); } } |