News for hackers. Stuff that matters.
Re:Declarative Shadow DOM by irishcarbomb777 on Monday February 13, 2023 @08:08PM (#34783701)
One nice way of handling this is to use the CSSStyleSheet object. In a nutshell, you can create a module like shadowCssRules.js and in that create a CSSStyleSheet object and set your global rules ( * { box-sizing: border-box;} ) then in your WebComponent constructor you call this.shadowRoot.adoptedStyleSheets = [shadowCssSheet]. This MDN page has an example at the bottom https://developer.mozilla.org/en-US/docs/Web/API/CSSStyleShe...

Also allows you to update the style sheet from anywhere in your js and it’ll effect all the shadow doms that adopted it

Re:Declarative Shadow DOM by jacobr on Tuesday February 14, 2023 @02:38PM (#34794768)
* * *