Change passive checker to use defineProperty (#15121)

This commit is contained in:
Dominic Gannaway
2019-03-15 22:24:25 +00:00
committed by GitHub
parent b283d75c17
commit 035e4cffbd
+5 -3
View File
@@ -16,11 +16,13 @@ export let passiveBrowserEventsSupported = false;
// https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener#Safely_detecting_option_support
if (enableEventAPI && canUseDOM) {
try {
const options = {
get passive() {
const options = {};
// $FlowFixMe: Ignore Flow complaining about needing a value
Object.defineProperty(options, 'passive', {
get: function() {
passiveBrowserEventsSupported = true;
},
};
});
window.addEventListener('test', options, options);
window.removeEventListener('test', options, options);
} catch (e) {