Skip to content

Commit

Permalink
Change passive checker to use defineProperty (#15121)
Browse files Browse the repository at this point in the history
  • Loading branch information
trueadm authored Mar 15, 2019
1 parent b283d75 commit 035e4cf
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions packages/react-dom/src/events/checkPassiveEvents.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 035e4cf

Please sign in to comment.