Last active
December 10, 2023 06:54
-
-
Save Tubeee/601561e967377dc646790e8e4dedc647 to your computer and use it in GitHub Desktop.
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
| export function createCustomElement(name, templateId) { | |
| const template = document.getElementById(templateId); | |
| class CustomElement extends HTMLElement { | |
| constructor() { | |
| super(); | |
| const shadowRoot = this.attachShadow({ mode: "open" }); | |
| shadowRoot.appendChild(template.content.cloneNode(true)); | |
| } | |
| } | |
| customElements.define(name, CustomElement); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment