This is a ponyfill for the type
property on ElementInternals
.
class CustomButton extends HTMLElement {
static formAssociated = true;
#internals = this.attachInternals();
constructor() {
super();
this.#internals.type = 'button';
}
}
customElements.define('custom-button', CustomButton);
When elementInternals.type = 'button'
is set in a custom element's constructor, the custom element will gain support for the attributes listed below.
- 🚀 Fully Typed: Full type safety and autocompletion
- 🧠 Fully Tested: Full 100% test coverage
- 📦 Tree-shakeable: Only import what you need
- ⚡ Performance Optimized: Efficient updates and rendering
npm install element-internals-type
Contributions are welcome!
- Fork the repository
- Create your feature branch (
git checkout -b your/amazing-feature
) - Commit your changes (
git commit -m "Add some amazing feature"
) - Push to the branch (
git push origin your/amazing-feature
) - Open a Pull Request
This project is licensed under the MIT No Attribution License.