The fact that we can now create a custom "button" directly in the browser, one that doesn't have the historical baggage of , or the baffling rigidity of the jack-of-all-trades , is something that should be celebrated. In some cases, we don't even need to include native form elements in our shadow DOM anymore, thanks to the ElementInternals API. ElementInternals handles both ARIA and form association, at a platform level. This means native forms can treat custom elements the same as any other form control, with field validation, label association, and value submission included. It's by no means a perfect solution yet, but it's better than everything we've had before it, and a lot of people are working very hard to make it better for everyone.
Framework-driven components literally can't do this. If they claim they can, it means they're either building custom elements wrapped in extra JS, or they're doing a LOT of heavy lifting to reproduce what's already available in the browser.
I've always had issues with front end frameworks, which is why I choose not to use them. I find that they make it dangerously easy to dig a hole too big to climb out of, especially when they bring their own abstractions that obfuscate what's actually being rendered on the page. There's too much "magic" that happens, and I don't appreciate the "just trust me, bro" vibes I get from how certain frameworks function (hooks, JSX, etc.).
To wrap this up, I can count the amount of times I've had to work professionally with React, Vue, and Angular combined on one hand. I guess the one I used most was Vue, and even then it was only for a few months before I started building custom elements in 2020.
I've seen no compelling reason to go back.
The above is the detailed content of Web Components are... Web Components. For more information, please follow other related articles on the PHP Chinese website!