-
Notifications
You must be signed in to change notification settings - Fork 3k
/
passiveeventlisteners.js
36 lines (36 loc) · 1.02 KB
/
passiveeventlisteners.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/*!
{
"property": "passiveeventlisteners",
"caniuse": "passive-event-listener",
"tags": ["dom"],
"authors": ["Rick Byers"],
"name": "Passive event listeners",
"notes": [{
"name": "WHATWG Spec",
"href": "https://dom.spec.whatwg.org/#dom-addeventlisteneroptions-passive"
}, {
"name": "WICG explainer",
"href": "https://github.com/WICG/EventListenerOptions/blob/gh-pages/explainer.md"
}]
}
!*/
/* DOC
Detects support for the passive option to addEventListener.
*/
define(['Modernizr'], function(Modernizr) {
Modernizr.addTest('passiveeventlisteners', function() {
var supportsPassiveOption = false;
try {
var opts = Object.defineProperty({}, 'passive', {
get: function() {
supportsPassiveOption = true;
return;
}
});
var noop = function () {};
window.addEventListener('testPassiveEventSupport', noop, opts);
window.removeEventListener('testPassiveEventSupport', noop, opts);
} catch (e) {}
return supportsPassiveOption;
});
});