I want to create a custom element class that can be use on basically any type of element if is="foo-element"
is present, but I get the feeling that it’s not possible.
The closest I have been able to come up with is this abomination.
const allTags = ["ul", "div" /* etc... */]
for (const tag of allTags) {
const baseCalss = document.createElement(tag).constructor
const customElement = class extends baseCalss {
constructor() { super() }
}
customElements.define("custom-element-"+tag, customElement, { extends: tag })
}
<ul is="custom-element-ul">
</ul>
<div is="custom-element-div">
</div>