Open jelmervdl opened 2 years ago
Oh oh we might even be able to support closed shadow roots! https://developer.mozilla.org/en-US/docs/Web/API/Element/openOrClosedShadowRoot
With #64 added we already have our own tree walker. Adding shadow dom support to that is now a lot easier 🎉
The page https://www.suewag.de/privatkunden uses custom elements to an extreme. From the DOM root almost no text is visible, it is all hidden inside the shadow roots of the custom elements.
Example script to actually get all the text on the page (and a bit more because it doesn't differentiate between things like
<div>
,<custom-element>
and<script>
)Similarly, the
InPageTranslation
class would need to be updated to be aware of shadowRoot. I'm not sure whether DOM mutations propagate from shadowRoot to the parent fragment or eventually the document.body tree?Ideally, we could use the accessibility tree directly to figure out text and translate that. That should contain all text that is relevant to translate, if pages are properly accessible. It is also something creators of custom elements can easily design for. But unfortunately nothing like that is being shipped yet.
There is the Accessibility Object Model, Phase 4 Draft which could be promising some day.