-
I noticed in the guides as well as the What's the For example, one may want to listen for a One could very well register it within the custom element with Are there plans to support this, or if not, what is your suggested strategy for dealing with event listeners on the global scope? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
We wanted to avoid global event listeners as we find they often do more harm than good, for the most part. There seems to be two common classes of global event listeners:
There's some validity to events that hang directly off of Hopefully this answers the question by providing justification for not adding these shorthands. If you want to discuss it further though, let's do so! |
Beta Was this translation helpful? Give feedback.
We wanted to avoid global event listeners as we find they often do more harm than good, for the most part. There seems to be two common classes of global event listeners:
click
on thewindow
and checking thetarget
. Event delegation is a good performance optimisation but can often be a premature one. Should a need arise for an element to have such an optimisation, it's probably good to state it explicitly. We don't want people to think it's the default. Adding a shorthand encourages this approach, we'd prefer to discourage it, as it comes with additional complexities (checking target, overly noisy callbacks, bubbling, propagation ordering,…