Skip to content

Commit 035e4cf

Browse files
authored
Change passive checker to use defineProperty (#15121)
1 parent b283d75 commit 035e4cf

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

packages/react-dom/src/events/checkPassiveEvents.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,13 @@ export let passiveBrowserEventsSupported = false;
1616
// https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener#Safely_detecting_option_support
1717
if (enableEventAPI && canUseDOM) {
1818
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() {
2123
passiveBrowserEventsSupported = true;
2224
},
23-
};
25+
});
2426
window.addEventListener('test', options, options);
2527
window.removeEventListener('test', options, options);
2628
} catch (e) {

0 commit comments

Comments
 (0)