Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
A generic lifecycle custom element for use in frameworks that don't implement lifecycle
customElements.define('life-cycle', class LifeCycle extends HTMLElement {
constructor(){
super()
}
connected(){}
connectedCallback(){
this.style.display = 'contents'
this.connected(...arguments)
}
disconnected(){}
disconnectedCallback(){
this.disconnected(...arguments)
}
updated(){}
attributeChangedCallback(x,y,z){
if(y !== z)
this.updated(...arguments)
}
static get observedAttributes(){
return ['dependencies']
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment