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 19 20 21 | 2x 2x 2x 2x 2x 2x 21x 21x 52x 36x 52x 1x 1x 1x 52x 21x 21x 34x 30x 21x | /**
* Traverse up in the document DOM closest element by passing shadow DOM
* @param {Element} targetElement - first element to yield from the generator
* @yields {Element} one element for each subsequent ancestor
*/
export function * traverseUpDom (targetElement) {
let el = targetElement
while (el != null) {
yield el
const { parentNode, parentElement } = el
if (parentNode instanceof ShadowRoot) {
el = parentNode.host
continue
}
if (parentNode instanceof Document || parentElement == null) {
return
}
el = parentElement
}
}
|