index.js 1.0 KB

1234567891011121314151617181920212223242526272829
  1. 'use strict';
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. // adapted from https://github.com/WICG/EventListenerOptions/blob/gh-pages/explainer.md
  6. var detectPassiveEvents = {
  7. update: function update() {
  8. if (typeof window !== 'undefined' && typeof window.addEventListener === 'function') {
  9. var passive = false;
  10. var options = Object.defineProperty({}, 'passive', {
  11. get: function get() {
  12. passive = true;
  13. }
  14. });
  15. // note: have to set and remove a no-op listener instead of null
  16. // (which was used previously), becasue Edge v15 throws an error
  17. // when providing a null callback.
  18. // https://github.com/rafrex/detect-passive-events/pull/3
  19. var noop = function noop() {};
  20. window.addEventListener('testPassiveEventSupport', noop, options);
  21. window.removeEventListener('testPassiveEventSupport', noop, options);
  22. detectPassiveEvents.hasSupport = passive;
  23. }
  24. }
  25. };
  26. detectPassiveEvents.update();
  27. exports.default = detectPassiveEvents;