handling events in webcomponents with handleEvent
last updated: Oct 01, 2024
basically, this:
customElements.define('awesome-sauce', class extends HTMLElement {
// Instantiate the component
constructor () {
super();
}
// Handle events
handleEvent (event) {
// ...
}
// Listen for events
connectedCallback () {
this.addEventListener('click', this);
this.addEventListener('input', this);
this.addEventListener('close', this);
}
});