inferno
inferno copied to clipboard
Support Passive Event Listeners
It would be nice to have support for passive events. Related: https://github.com/facebook/react/issues/6436
Currently Inferno adds events using inline way. equivalent to:
<div onclick="function() {}"></div>
To support this feature new way of handling methods is needed. We used to use addEventListener, but that resulted memory leaks and slow rendering because of removeEventListener (to avoid that leak).
@Havunen this is now a possibility again with our new event system.
Let's revisit this post 1.0.
Add to roadmap @lukeed
Re-opening as this was never implemented
This looks good, this would have effects in performance. But as far as I have read, this would only be applicable for events that's related to scrolling --> https://developers.google.com/web/tools/lighthouse/audits/passive-event-listeners. Inferno could handle it by supporting event options like so:
<span onScroll={{
handler (ev) {
// do something
},
options: {
passive: true
}
}}>
OR adding it automatically when the event listener is related to scrolling.
There's even a demo video about this --> https://youtu.be/65VMej8n23A
I think it's good for inferno to support passive listener for onScroll by default.