I tried to define click event handler as elements class method
Why it is not working?
class Component extends HTMLElement {
...
onclick () {
console.log(event)
}
}
But it works in this way
class Component extends HTMLElement {
constructor() {
super()
this.onclick = console.log
}
}
ES7+ way
class CustomElement extends HTMLElement {
onclick = () => {...}
}