Everything I've read indicates that the Shadow Dom is supposed to be 'safe' from its parent page CSS. I.E. if I have all divs styled to have purple font:
<style>
div{color: purple}
</style>
The divs in my Shadow Dom should have the browser default color.
I am writing a chrome extension that injects html into any given page. Unless this html is protected by either Shadow Dom or Iframe, it will inherit all the page's CSS.
The advice to solve this problem in this question, was to use the Shadow Dom. So I implemented a solution, but noticed it was inheriting the page's CSS still. I thought this might have been an issue with using it in a Chrome extension, so I hijacked a jsBin from some Shadow Dom examples (and threw it in another live coding app for good measure).
https://codepen.io/hyrumwhite/pen/xPRexQ
Same result. My shadow DOM inherits the page CSS, and my divs (and weirdly my h1) are purple.
It looks like the children in the Shadow Dom will inherit any styling applied to the host element.
Is this working as designed? Is there a way to prevent this? Or is the shadow DOM new enough that this is a bug and I should expect similar bugs as I keep using it?