Skip to content

Instantly share code, notes, and snippets.

@JanDW
Created January 16, 2025 22:59
Show Gist options
  • Save JanDW/57c741df401583e88c403afb28cc5df2 to your computer and use it in GitHub Desktop.
Save JanDW/57c741df401583e88c403afb28cc5df2 to your computer and use it in GitHub Desktop.
<script>
// Creates MyElements extending HTML Element
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);
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment