Mark event as explicitly NOT passive
up vote
1
down vote
favorite
[Violation] Added non-passive event listener to a scroll-blocking 'wheel' event. Consider marking event handler as 'passive' to make the page more responsive.
This warning is kinda getting on my nerves to be honest. I have an event where I sometimes need to call preventDefault()
Is there a way to mark the event as explicitly NOT passive and to get rid of this warning? I know it doesn't hamper execution flow, but it's an annoyance. All I can find is how to mark it passive, but it's a desktop app, which doesn't need the passive marker for scroll optimization.
I'm not sure what chrome thought when they implemented this as default warning to clutter up the dev console. I feel like it's something like the agree button now on EULAS, don't read, just click ok, cookie warning, just click ok...
I don't wish to fix it, I wish to ignore it, consiously.
javascript google-chrome events
add a comment |
up vote
1
down vote
favorite
[Violation] Added non-passive event listener to a scroll-blocking 'wheel' event. Consider marking event handler as 'passive' to make the page more responsive.
This warning is kinda getting on my nerves to be honest. I have an event where I sometimes need to call preventDefault()
Is there a way to mark the event as explicitly NOT passive and to get rid of this warning? I know it doesn't hamper execution flow, but it's an annoyance. All I can find is how to mark it passive, but it's a desktop app, which doesn't need the passive marker for scroll optimization.
I'm not sure what chrome thought when they implemented this as default warning to clutter up the dev console. I feel like it's something like the agree button now on EULAS, don't read, just click ok, cookie warning, just click ok...
I don't wish to fix it, I wish to ignore it, consiously.
javascript google-chrome events
add a comment |
up vote
1
down vote
favorite
up vote
1
down vote
favorite
[Violation] Added non-passive event listener to a scroll-blocking 'wheel' event. Consider marking event handler as 'passive' to make the page more responsive.
This warning is kinda getting on my nerves to be honest. I have an event where I sometimes need to call preventDefault()
Is there a way to mark the event as explicitly NOT passive and to get rid of this warning? I know it doesn't hamper execution flow, but it's an annoyance. All I can find is how to mark it passive, but it's a desktop app, which doesn't need the passive marker for scroll optimization.
I'm not sure what chrome thought when they implemented this as default warning to clutter up the dev console. I feel like it's something like the agree button now on EULAS, don't read, just click ok, cookie warning, just click ok...
I don't wish to fix it, I wish to ignore it, consiously.
javascript google-chrome events
[Violation] Added non-passive event listener to a scroll-blocking 'wheel' event. Consider marking event handler as 'passive' to make the page more responsive.
This warning is kinda getting on my nerves to be honest. I have an event where I sometimes need to call preventDefault()
Is there a way to mark the event as explicitly NOT passive and to get rid of this warning? I know it doesn't hamper execution flow, but it's an annoyance. All I can find is how to mark it passive, but it's a desktop app, which doesn't need the passive marker for scroll optimization.
I'm not sure what chrome thought when they implemented this as default warning to clutter up the dev console. I feel like it's something like the agree button now on EULAS, don't read, just click ok, cookie warning, just click ok...
I don't wish to fix it, I wish to ignore it, consiously.
javascript google-chrome events
javascript google-chrome events
edited Jun 7 '17 at 7:37
asked Jun 7 '17 at 7:32
Tschallacka
14.7k55086
14.7k55086
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
up vote
1
down vote
accepted
Specify passive: false when you add the listener:
el.addEventListener('click', someFn, passive: false );
See: https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener
You're my hero. and for those who google this ;-)
– Tschallacka
Jun 7 '17 at 7:56
Should there be a note that for browsers that don't supportoptions
, it will setuseCapture
to true ? developer.mozilla.org/en-US/docs/Web/API/EventTarget/…
– Kaiido
Jun 7 '17 at 10:46
add a comment |
up vote
0
down vote
The above solution works but requires a change to each call to addEventListener.
If you would prefer to silence the warnings through a single change that impacts all calls to addEventListener that you've already written in old form, you can do something like the following (modified from https://stackoverflow.com/a/49292829/3160967). You can further modify this if you want it to selectively handle / report / etc.
var addEventListener_orig = EventTarget.prototype.addEventListener;
EventTarget.prototype.addEventListener = function(type, handler, opts_orig) ;
Please note, as this modifies the base object, third party libraries might act differently (though I cannot think of any scenario where that could actually happen, unless the 3p library would also monkey patch addEventListener, as the above, if I'm not mistake, just fills in the default values that otherwise get used when none were explicitly provided, and by doing so makes the warning go away)
Please note that if you modify the base object, third party libraries might act differently, since they might not expect the changes made.
– Tschallacka
Jun 15 at 7:37
Thank you! added-- if you don't agree with the added comment that the code is just explicitly stating the values that would implicitly be used, please lmk
– mwag
Jun 19 at 21:59
add a comment |
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
accepted
Specify passive: false when you add the listener:
el.addEventListener('click', someFn, passive: false );
See: https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener
You're my hero. and for those who google this ;-)
– Tschallacka
Jun 7 '17 at 7:56
Should there be a note that for browsers that don't supportoptions
, it will setuseCapture
to true ? developer.mozilla.org/en-US/docs/Web/API/EventTarget/…
– Kaiido
Jun 7 '17 at 10:46
add a comment |
up vote
1
down vote
accepted
Specify passive: false when you add the listener:
el.addEventListener('click', someFn, passive: false );
See: https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener
You're my hero. and for those who google this ;-)
– Tschallacka
Jun 7 '17 at 7:56
Should there be a note that for browsers that don't supportoptions
, it will setuseCapture
to true ? developer.mozilla.org/en-US/docs/Web/API/EventTarget/…
– Kaiido
Jun 7 '17 at 10:46
add a comment |
up vote
1
down vote
accepted
up vote
1
down vote
accepted
Specify passive: false when you add the listener:
el.addEventListener('click', someFn, passive: false );
See: https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener
Specify passive: false when you add the listener:
el.addEventListener('click', someFn, passive: false );
See: https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener
answered Jun 7 '17 at 7:40
Evan Trimboli
26.2k33352
26.2k33352
You're my hero. and for those who google this ;-)
– Tschallacka
Jun 7 '17 at 7:56
Should there be a note that for browsers that don't supportoptions
, it will setuseCapture
to true ? developer.mozilla.org/en-US/docs/Web/API/EventTarget/…
– Kaiido
Jun 7 '17 at 10:46
add a comment |
You're my hero. and for those who google this ;-)
– Tschallacka
Jun 7 '17 at 7:56
Should there be a note that for browsers that don't supportoptions
, it will setuseCapture
to true ? developer.mozilla.org/en-US/docs/Web/API/EventTarget/…
– Kaiido
Jun 7 '17 at 10:46
You're my hero. and for those who google this ;-)
– Tschallacka
Jun 7 '17 at 7:56
You're my hero. and for those who google this ;-)
– Tschallacka
Jun 7 '17 at 7:56
Should there be a note that for browsers that don't support
options
, it will set useCapture
to true ? developer.mozilla.org/en-US/docs/Web/API/EventTarget/…– Kaiido
Jun 7 '17 at 10:46
Should there be a note that for browsers that don't support
options
, it will set useCapture
to true ? developer.mozilla.org/en-US/docs/Web/API/EventTarget/…– Kaiido
Jun 7 '17 at 10:46
add a comment |
up vote
0
down vote
The above solution works but requires a change to each call to addEventListener.
If you would prefer to silence the warnings through a single change that impacts all calls to addEventListener that you've already written in old form, you can do something like the following (modified from https://stackoverflow.com/a/49292829/3160967). You can further modify this if you want it to selectively handle / report / etc.
var addEventListener_orig = EventTarget.prototype.addEventListener;
EventTarget.prototype.addEventListener = function(type, handler, opts_orig) ;
Please note, as this modifies the base object, third party libraries might act differently (though I cannot think of any scenario where that could actually happen, unless the 3p library would also monkey patch addEventListener, as the above, if I'm not mistake, just fills in the default values that otherwise get used when none were explicitly provided, and by doing so makes the warning go away)
Please note that if you modify the base object, third party libraries might act differently, since they might not expect the changes made.
– Tschallacka
Jun 15 at 7:37
Thank you! added-- if you don't agree with the added comment that the code is just explicitly stating the values that would implicitly be used, please lmk
– mwag
Jun 19 at 21:59
add a comment |
up vote
0
down vote
The above solution works but requires a change to each call to addEventListener.
If you would prefer to silence the warnings through a single change that impacts all calls to addEventListener that you've already written in old form, you can do something like the following (modified from https://stackoverflow.com/a/49292829/3160967). You can further modify this if you want it to selectively handle / report / etc.
var addEventListener_orig = EventTarget.prototype.addEventListener;
EventTarget.prototype.addEventListener = function(type, handler, opts_orig) ;
Please note, as this modifies the base object, third party libraries might act differently (though I cannot think of any scenario where that could actually happen, unless the 3p library would also monkey patch addEventListener, as the above, if I'm not mistake, just fills in the default values that otherwise get used when none were explicitly provided, and by doing so makes the warning go away)
Please note that if you modify the base object, third party libraries might act differently, since they might not expect the changes made.
– Tschallacka
Jun 15 at 7:37
Thank you! added-- if you don't agree with the added comment that the code is just explicitly stating the values that would implicitly be used, please lmk
– mwag
Jun 19 at 21:59
add a comment |
up vote
0
down vote
up vote
0
down vote
The above solution works but requires a change to each call to addEventListener.
If you would prefer to silence the warnings through a single change that impacts all calls to addEventListener that you've already written in old form, you can do something like the following (modified from https://stackoverflow.com/a/49292829/3160967). You can further modify this if you want it to selectively handle / report / etc.
var addEventListener_orig = EventTarget.prototype.addEventListener;
EventTarget.prototype.addEventListener = function(type, handler, opts_orig) ;
Please note, as this modifies the base object, third party libraries might act differently (though I cannot think of any scenario where that could actually happen, unless the 3p library would also monkey patch addEventListener, as the above, if I'm not mistake, just fills in the default values that otherwise get used when none were explicitly provided, and by doing so makes the warning go away)
The above solution works but requires a change to each call to addEventListener.
If you would prefer to silence the warnings through a single change that impacts all calls to addEventListener that you've already written in old form, you can do something like the following (modified from https://stackoverflow.com/a/49292829/3160967). You can further modify this if you want it to selectively handle / report / etc.
var addEventListener_orig = EventTarget.prototype.addEventListener;
EventTarget.prototype.addEventListener = function(type, handler, opts_orig) ;
Please note, as this modifies the base object, third party libraries might act differently (though I cannot think of any scenario where that could actually happen, unless the 3p library would also monkey patch addEventListener, as the above, if I'm not mistake, just fills in the default values that otherwise get used when none were explicitly provided, and by doing so makes the warning go away)
edited Jun 19 at 21:57
answered Jun 15 at 3:08
mwag
884820
884820
Please note that if you modify the base object, third party libraries might act differently, since they might not expect the changes made.
– Tschallacka
Jun 15 at 7:37
Thank you! added-- if you don't agree with the added comment that the code is just explicitly stating the values that would implicitly be used, please lmk
– mwag
Jun 19 at 21:59
add a comment |
Please note that if you modify the base object, third party libraries might act differently, since they might not expect the changes made.
– Tschallacka
Jun 15 at 7:37
Thank you! added-- if you don't agree with the added comment that the code is just explicitly stating the values that would implicitly be used, please lmk
– mwag
Jun 19 at 21:59
Please note that if you modify the base object, third party libraries might act differently, since they might not expect the changes made.
– Tschallacka
Jun 15 at 7:37
Please note that if you modify the base object, third party libraries might act differently, since they might not expect the changes made.
– Tschallacka
Jun 15 at 7:37
Thank you! added-- if you don't agree with the added comment that the code is just explicitly stating the values that would implicitly be used, please lmk
– mwag
Jun 19 at 21:59
Thank you! added-- if you don't agree with the added comment that the code is just explicitly stating the values that would implicitly be used, please lmk
– mwag
Jun 19 at 21:59
add a comment |
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f44406297%2fmark-event-as-explicitly-not-passive%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown