News for hackers. Stuff that matters.
Re:Introducing react.dev by epolanski on Thursday March 16, 2023 @05:26PM (#35188913)
And yet the sanest option for this, web components, keeps struggling.
Re:Introducing react.dev by r3trohack3r on Thursday March 16, 2023 @06:15PM (#35189574)
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.

Re:Introducing react.dev by epolanski on Friday March 17, 2023 @05:54AM (#35195047)
That'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.