Skip to content

Commit

Permalink
feat: add shadow root handling
Browse files Browse the repository at this point in the history
  • Loading branch information
deleonio committed Apr 9, 2022
1 parent 6b69483 commit 8dca5de
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/assemble/_landmarksFinder.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,12 @@ export default function LandmarksFinder(win, doc, _testUseHeuristics) {
parentLandmark = element
}

if(element.shadowRoot) {
for (const elementChild of element.shadowRoot.children) {
getLandmarks(elementChild, depth, parentLandmark)
}
}

// One just one page I've seen an error here in Chrome (91) which seems
// to be a bug, because only one HTMLElement was returned; not an
// HTMLCollection. Checking for this would cause a slowdown, so
Expand Down Expand Up @@ -367,6 +373,9 @@ export default function LandmarksFinder(win, doc, _testUseHeuristics) {
reversePath.push(description)
if (id) break
node = node.parentNode
while(typeof node.tagName !== 'string') {
node = node.host
}
}

return reversePath.reverse().join(' > ')
Expand Down

0 comments on commit 8dca5de

Please sign in to comment.