3 ms·
I've been using WebComponents a lot lately. My biggest gripe with them as a technology is that they have no way to associate a `<style>` tag in `<head>` with a
by r3trohack3r 4y ago
I've been using WebComponents a lot lately.
My biggest gripe with them as a technology is that they have no way to associate a `<style>` tag in `<head>` with a ShadowDOM tree (short of cloning and injecting w/ JS).
The only way to say "this CSS goes with this <template>" is to nest the `<style>` tag in `<template>` itself or painstakingly expose `part`s on everything you want to style.
I'd really like a template selector for CSS where I can say something like `::template(#id) button` to select all buttons inside the `<template id="id">` for whatever ShadowDOM it is mounted to.
Without this, I either have to do CSS in JS, CSS in HTML, or I have to use special build magic to take my standard index.css files and inject them into my HTML or JS. All of that is kinda gross.
- epolanski 4y agoThat's how it is intended to work to avoid that using two web components on two different websites leads to major inconsistencies because the root shares several classes. If you want to support your case, you either inject css or you design your web components to support css variables which pierce throgh the shadow dom.