Bunch of things I learned about web components
is is cool but not really
Genuinely think Safari is the new Internet Explorer. I was excited to learn about HTML’s 'is' attribute. Seems like a great way to progressively enhance HTML with custom elements. Then I discovered Safari won’t support it.
Would have been nice to do the following but it wouldn't have worked in Safari:
Custom Elements Manifest
It's a thing: https://github.com/webcomponents/custom-elements-manifest
Storybook support for web components is a rough around the edges
- Have to call
customElements.definein thepreview.jsfile for each component @storybook/web-componentsis a poorly documented.- Kinda supports the custom elements manifest via
setCustomElementsManifestbut it but seems to only work whencustomElements.defineis called in the component's source file?
Linting
There's a plugin for Web Components that is handy for catching things like is not being recommended: https://github.com/43081j/eslint-plugin-wc
Making it easy to register the element
A few approaches I've seen so far:
A static method:
A static property:
🚩 tagName is part of the DOM standard though! This isn't a good approach because the element could be defined with a different tag name.