Created
January 16, 2025 23:00
-
-
Save JanDW/ce889bb0af9abedb6c51a77f5db69a1e to your computer and use it in GitHub Desktop.
Web component boilerplate with lifecycle callbacks.
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
class MyElement extends HTMLElement { | |
// Fires when an instance of the element is created or updated | |
constructor() { | |
super(); | |
} | |
// Fires when an instance was inserted into the document | |
connectedCallback() { | |
} | |
// Fires when an instance was removed from the document | |
disconnectedCallback() { | |
} | |
// Fires when an attribute was added, removed, or updated | |
attributeChangedCallback(attrName, oldVal, newVal) { | |
} | |
// Fires when an element is moved to a new document | |
adoptedCallback() { | |
} | |
} | |
// Registers custom element | |
window.customElements.define('my-element', MyElement); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment