3 ms·
I’ve been adding global listeners for click and keydown that call handleFoo(event) if event.target has a data-foo attribute. The Invoker API seems like a neate
by gorgoiler 7mo ago
I’ve been adding global listeners for click and keydown that call handleFoo(event) if event.target has a data-foo attribute.
The Invoker API seems like a neater way of handling the same pattern but I’m biased towards global event listeners because they work automatically on newly injected markup and they scale O(functionality) as opposed to per element listeners that scale O(elements). I’ll be the first to admit that the latter is more of an aesthetic choice rather than being based on any kind of performance statistics.
- 8n4vidtmkvmk 7mo agoO(depth) too, no? The events have to bubble up to the window before triggering your handler.