@samitouri / QOS-React / commits / 035e4cffbd

Change passive checker to use defineProperty (#15121)

Dominic Gannaway committed Mar 15, 2019 at 22:24 UTC 035e4cffbd16fd618ed1a5614838656a4a505936
1 file changed +5 -3
packages/react-dom/src/events/checkPassiveEvents.js
+5 -3
@@ -16,11 +16,13 @@ export let passiveBrowserEventsSupported = false;
16 // https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener#Safely_detecting_option_support
17 if (enableEventAPI && canUseDOM) {
18 try {
19 - const options = {
20 - get passive() {
19 + const options = {};
20 + // $FlowFixMe: Ignore Flow complaining about needing a value
21 + Object.defineProperty(options, 'passive', {
22 + get: function() {
23 passiveBrowserEventsSupported = true;
24 },
23 - };
25 + });
26 window.addEventListener('test', options, options);
27 window.removeEventListener('test', options, options);
28 } catch (e) {