Shadow-Piercing descendant combinator, '/deep/' , including '::shadow' pseudo elements, are being deprecated so how do we pierce the Shadow DOM?

前端 未结 1 689
遥遥无期
遥遥无期 2021-01-12 16:01

Let\'s say we had some CSS code for something like an animated CSS loader that we want to use across all our web components which make use of the Shadow DOM. How do we re-us

相关标签:
1条回答
  • 2021-01-12 16:47

    Rather than using <link />, I'd suggest you to use css @imports inside shadow root to load external stylesheets where ever needed.
    I have written an answer here on the topic. Quoting it below for reference.

    You can create a style.css and import it in your components by putting a css @import in your template. There won't be multiple network calls, since browser is going to cache it when your first component loads and for subsequent components it will picked from cache.

    0 讨论(0)
提交回复
热议问题