Created
May 9, 2021 10:46
-
-
Save ashwinkumar2438/24ada020643b780338f0c569c34b8a96 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
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