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.



enter image description here










share|improve this question



























    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.



    enter image description here










    share|improve this question

























      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.



      enter image description here










      share|improve this question
















      [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.



      enter image description here







      javascript google-chrome events






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Jun 7 '17 at 7:37

























      asked Jun 7 '17 at 7:32









      Tschallacka

      14.7k55086




      14.7k55086






















          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






          share|improve this answer




















          • 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

















          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)






          share|improve this answer






















          • 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










          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













           

          draft saved


          draft discarded


















          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

























          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






          share|improve this answer




















          • 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














          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






          share|improve this answer




















          • 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












          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






          share|improve this answer












          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







          share|improve this answer












          share|improve this answer



          share|improve this answer










          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 support options, it will set useCapture 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










          • 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















          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












          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)






          share|improve this answer






















          • 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














          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)






          share|improve this answer






















          • 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












          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)






          share|improve this answer














          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)







          share|improve this answer














          share|improve this answer



          share|improve this answer








          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
















          • 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

















           

          draft saved


          draft discarded















































           


          draft saved


          draft discarded














          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





















































          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







          這個網誌中的熱門文章

          How to read a connectionString WITH PROVIDER in .NET Core?

          In R, how to develop a multiplot heatmap.2 figure showing key labels successfully

          Museum of Modern and Contemporary Art of Trento and Rovereto