Google Chrome Violation: Added non-passive event
aletheia7 opened this issue · 3 comments
Google Chrome Console Error
[Violation] Added non-passive event listener to a scroll-blocking 'touchstart' event. Consider marking event handler as 'passive' to make the page more responsive. See https://www.chromestatus.com/feature/5745543795965952
macOS: Big Sur
Google Chrome: 89.0.4389.82
iro.js: v5.3.2
iro.js line 14
iro.js chrome formatted: line 241
Code
... u ? (t || n.addEventListener(l, T, e), ...
l = onmousedown
e = false
e should probably be { passive: true }
also
l = ontouchstart
e = false
https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener
I intentionally mark them as non-passive: https://github.com/jaames/iro.js/blob/master/src/ComponentWrapper.tsx#L83 , since they call preventDefault() to stop the page from scrolling while users drag the color picker handles
The error isn't fatal, it's just a minor warning since most people don't have any reason to use touch events in this way
When I sent a breakpoint, e is a boolean. e is not an object with passive set to false.
Would the Violation disappear if e was {passive: false} ?
Ah, looks like that code is coming from Preact, so not sure if there's anything I can do about that.
Relevant Preact issue:
preactjs/preact#428