3 ms·
I know a lot of people are excited about them, but I still have problems with how web components are being designed. Custom elements feel like we're moving in
by danShumway 8y ago
I know a lot of people are excited about them, but I still have problems with how web components are being designed.
Custom elements feel like we're moving in the opposite direction from semantic markup - they just degrade into divs, so they're not particularly meaningful unless the DOM used to construct them is also descriptive and meaningful. So immediately we get Shadow DOM which hides a bunch of stuff from the end user. It's really clearly bad for accessibility and user control.
Beyond that, it's not clear to me what problem we're solving:
- Integrated templates into HTML: Okay, I get it, potentially useful. You don't need custom elements for that.
- Blocking global CSS from styling your components: Valid, but this is a really hacky way to solve that problem. What we'd prefer is CSS boundaries that don't require JS to use.
The main thing seems to be that people think the code looks cleaner than using divs and CSS classes. Which... great, I kind of agree. But why should I be so excited about what basically boils down to syntactic sugar?
The one super useful, really exciting part of web components was HTML import. HTML imports would have been amazing.
But that effort has been messed up as well - it relies on Javascript. We can already use Javascript to make AJAX requests and append content to the DOM. What we can't do is include a single header across multiple pages without building either a webapp or a preprocessor.
I think Mozilla is in the right to have dragged their feet so much on this. Beyond shadow DOM, which I'm nonplussed about, what is now possible with modern web components that wasn't already possible 3-5 years ago?