DEV Community

Discussion on: The Quirks of Shadow DOM and How to Take Advantage of Them

brianboyko profile image
Brian Boyko

This is all very, very good information. I'm just disappointed in that it does illustrate why you would also NOT want to use web components in a lot of cases. Specifically, when you said:

this is the biggest reason why we say that Shadow DOM fixes CSS, everything has it's own scope.

Honestly, that's not what I expect CSS behaviour to be. To me, not being able to alter the styling of items in the shadow dom from the light dom breaks CSS - specifically, the rules about CSS specificity and cascading that we've been working with for the past 20 years.

It does make my particular use case problematic.

Right now my team lead is REALLY pushing for web components to be used as the base of a UI library; but the problem is that if our end-users can't alter the CSS inside of a web-component, then if the CSS doesn't match 100% what they need it to be, they have to write an entirely new custom component from scratch instead of using the UI library (defeating the purpose of having a reusable UI library.) Or, alternatively, they could ask for changes to be made in the UI library itself... if they're willing to wait in the queue for their issue to be resolved.

All of this would be acceptable if there was a way to turn off CSS Encapsulation without turning off functionality, but there isn't.

This is a classic case of where code written to prevent stupid people from doing stupid things also prevents clever people from doing clever things.