Over engineer ElementOnce web components

This commit is contained in:
2026-03-26 23:25:29 +01:00
parent 3bc4f1300e
commit efdf71d69e
2 changed files with 101 additions and 60 deletions

View File

@@ -36,6 +36,7 @@ export function registerComponent(name: string, options?: ElementDefinitionOptio
**/
export function inheritHtmlElement<K extends keyof HTMLElementTagNameMap>(tagName: K) {
return class Inherited extends HTMLElement {
readonly inheritedTagName = tagName;
protected node: HTMLElementTagNameMap[K];
connectedCallback(autoAddNode?: boolean) {