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.
It's wrong - both that it's general "current advice", and the advice itself when it does pop up.
Yes, there are some people who say to build web components without shadow DOM, but I'm convinced they're only building leaf nodes so they don't need composition with slots. As soon as they try to build any kind of container element they hit big problems.
In a parallel discussion happening on Mastodon, someone says:
> People coming from React-land can have a hard time reasoning about the difference between a custom element and a template render function and when best to use each
> This abuse of the component system can indeed lead to a massive explosion in nodes on a page and the performance tanks because of that
I know I certainly have that hard time deciding when I need a custom element and when a render function.
> As soon as they try to build any kind of container element they hit big problems.
That's not true. Web components that render nothing will contain only their children as nodes, that's good enough for a good amount of container use cases.
Web Components Community Group: 2022. You are one of the authors:
--- 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.
...
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
...
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.
--- end quote ---
Those are just the tip of the iceberg as these are very explicitly stated in the doc.
Then there's the issues of shifting the responsibility to both developers and consumers to handle Shadow DOM correctly.
Styling/themeing is still pain despite several different specs like shadow parts.
Shadow DOM is a kind of retcon for the web. As I’ve written in the past, shadow DOM upends a lot of developer expectations and invalidates many tried-and-true techniques that worked fine in the pre-shadow DOM world.
Perhaps I care about the direction in which the web is pushed by a very small number of people incapable of seeing beyond their solutions and incapable of admitting their own mistakes.
At no point have I ever gotten the impression that you are even remotely open to seeing other points of view so it’s a bit hard to take the moralistic tone of the brave defender of the web part seriously. I think you just want to yell at people.
Web Components have been in development for 14 years. If you think this is the first discussion of web components, you clearly haven't been paying attention.
All there is to say was said years ago. Today it should be enough to know that, for example, "form associated custom elements cannot be a submit button" issue was opened 6 years ago, in 2019: https://github.com/WICG/webcomponents/issues/814
Imagine if any web framework had issues like that.
That doesn't even begin to cover things like "now every useful spec has to be acutely aware of Shadow DOM shenanigans" which delayed any number of specs like scoped CSS etc
It’s just like an LLM stuck on a loop. It’s just years and years of making the exact same comments, not responding to any counter arguments and then demanding that people take you seriously.
Could you provide the source for this advice?