Created
December 9, 2023 06:46
-
-
Save guiseek/c223b3cfb73825959e5e46dd921d7230 to your computer and use it in GitHub Desktop.
Custom element extend eecorator
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
interface CustomConstructor<K extends keyof HTMLElementTagNameMap> | |
extends CustomElementConstructor { | |
new (...params: any[]): HTMLElementTagNameMap[K] | |
prototype: HTMLElementTagNameMap[K] | |
} | |
export const extend = <K extends keyof HTMLElementTagNameMap>(inherite: K) => { | |
return <T extends CustomConstructor<K>>(target: T) => { | |
customElements.define(`txs-${inherite}`, target, {extends: inherite}) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment