Most active commenters
  • kubb(3)

←back to thread

277 points merqurio | 11 comments | | HN request time: 0.441s | source | bottom
Show context
Muromec ◴[] No.45113989[source]
I had lit in a project at work and not having to deal with it anymore is just great. We already have another heavier component framework to do the actual application stuff anyway, so having two just because somebody wanted to optimize their resume was such a drag.

It all looked nice in theory, but one thing shadow DOM makes worse is A11y, because element ids are now scoped and all the missing describe-by, label-for for things that should link to other side of the fence are a massive pain in the ass.

Big part of it is just skill issue on our part of course.

replies(4): >>45114885 #>>45117839 #>>45127177 #>>45149778 #
1. kubb ◴[] No.45114885[source]
Shadow DOM is optional in Lit - you can just disable it on a per-component basis.
replies(2): >>45116012 #>>45116762 #
2. sauercrowd ◴[] No.45116012[source]
causes a bunch of things to no longer work though - slots, style encapsulation, ...
replies(2): >>45116907 #>>45120325 #
3. jazzypants ◴[] No.45116762[source]
It should not be the default. This is almost certainly Lit's biggest flaw.

I am currently working on a web components framework, and I scrapped everything halfway through after I realized that you very rarely want that much encapsulation. Now, you can turn it on if you really need it, and I even made a way where you can pass references to DOM elements and stylesheets and such into each component so you can pierce the shadow veil easily. I have one demo to show it off, but I'm really having trouble imagining when someone would actually want to use it. The only time I can imagine it being useful would be building component libraries inside of large organizations.

I'm not ready to show off my framework yet, but I'm very certain that this leads to a better DX.

replies(2): >>45116920 #>>45117544 #
4. kubb ◴[] No.45116907[source]
If you need style encapsulation, use the Shadow DOM. Slots still work IIRC.
replies(1): >>45117025 #
5. kubb ◴[] No.45116920[source]
Good luck with your better framework, but if this is the biggest flaw… then there’s really not much to complain about.
replies(1): >>45117160 #
6. jfagnani ◴[] No.45117025{3}[source]
Slots definitely don't work without shadow DOM and there's really no way to make them work. It's the biggest problem with turning shadow DOM off.
7. jazzypants ◴[] No.45117160{3}[source]
Thanks! That's hardly the biggest difference to Lit. I think Lit is a fantastic framework, and I'm not trying to replace it or anything. However, it's really unopinionated which is fantastic for flexibility, but it leads to every deployment looking and feeling very different.

Basically, I'm just curious what a full-stack web component framework with strong defaults could look like. This is primarily a learning exercise, and a way to experiment with integrating web components into modern framework concepts like streaming server components, resumability, automatic serialization, and type-safe RPCs. I don't know if it will ever be production-ready, but I've learned a lot and it's been a ton of fun.

replies(1): >>45118723 #
8. Muromec ◴[] No.45117544[source]
>The only time I can imagine it being useful would be building component libraries inside of large organizations.

That was our use case and we are migrating away from custom elements to a more conservative approach.

9. __oh_es ◴[] No.45118723{4}[source]
Have you seen https://brisa.build/? Its not web-components first but it looks really well designed and may give you some inspo
10. troupo ◴[] No.45120325[source]
And that's the biggest problem with Shadow DOM (and most web component specs): you can't chose the good parts. Style encapsulation is useful, slots are useful, Shadow DOM is just all around bad, having a crazy amount of edge cases and broken behaviours [1].

Can you use style encapsulation and slots without Shadow DOM? Why can't you? I only need the horse, not the horse, and the cart, and the driver, and all the cargo in the cart.

You can't because people pushing all this stuff forward never ever stopped to think whether this was a good idea, and never ever talked to anyone outside of their own group.

[1] I will keep quoting this report by Web Components Working Group to death:

--- start quote --

It's worth noting that many of these pain points are directly related to Shadow DOM's encapsulation. While there are many benefits to some types of widely shared components to strong encapsulation, the friction of strong encapsulation has prevented most developers from adopting Shadow DOM, to the point of there being alternate proposals for style scoping that don't use Shadow DOM. We urge browser vendors to recognize these barriers and work to make Shadow DOM more usable by more developers.

...

Shadow boundaries prevent content on either side of the boundary from referencing each other via ID references. ID references being the basis of the majority of the accessibility patters outlines by aria attributes, this causes a major issue in developing accessible content with shadow DOM. While there are ways to develop these UIs by orchestrating the relationships between elements of synthesizing the passing of content across a shadow boundary, these practices generally position accessible development out of reach for most developers, both at component creation and component consumption time.

...

Selection does not work across or within shadow roots. This makes fully-featured rich-text editors impossible to implement with web components. Some of the web's most popular editors have issues that are blocked on this functionality.

--- end quote ---

replies(1): >>45125180 #
11. sauercrowd ◴[] No.45125180{3}[source]
That was exactly my experience using it. Great at first, and then hitting real-world and being stuck with the lack of sharing styles (in my case).

Shadow DOM was an absolute pain in reality.