Skip to content

Instantly share code, notes, and snippets.

@ashwinkumar2438
Created May 9, 2021 10:46
Show Gist options
  • Save ashwinkumar2438/24ada020643b780338f0c569c34b8a96 to your computer and use it in GitHub Desktop.
Save ashwinkumar2438/24ada020643b780338f0c569c34b8a96 to your computer and use it in GitHub Desktop.
class MyElement extends HTMLElement{
constructor(){
super();
console.log('element is instantiated.');
}
connectedCallback(){
console.log('element is connected and added to the DOM tree.')
}
disconnectedCallback(){
console.log('element is disconnected and removed from DOM tree.')
}
static get observedAttributes(){
return ['observed-attr']
}
attributeChangedCallback(name,oldValue,newValue){
console.log(`attribute ${name}'s value has been changed from ${oldValue} to ${newValue}`);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment