Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add shadow root handling #476

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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(node.host) {
node = node.host
}
}

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