IMO modern web language should have some notion of events as in my Sciter ( https://sciter.com/event-handling/ ) for example:
event click $(table > thead > tr > th) {
// click on table header cell
// 'this' is that th element
}
class Widget : Element
{
function attached() {...}
event click $(span.up) { this.increment(); }
event click $(span.down) { this.decrement(); }
event mousedown { this.state.focus = true; }
...
}