@samitouri / QOS-React-2 / commits / 55bc393f72

[Flare] Ensure we check for bad polyfill when creating responders (#16243)

Dominic Gannaway committed Jul 29, 2019 at 21:16 UTC 55bc393f726ddf3def83ca5a43cfc38a45d2e421
1 file changed +5 -1
packages/shared/createEventResponder.js
+5 -1
@@ -8,6 +8,7 @@
8
9 import type {ReactEventResponder} from 'shared/ReactTypes';
10 import {REACT_RESPONDER_TYPE} from 'shared/ReactSymbols';
11 +import {hasBadMapPolyfill} from './hasBadMapPolyfill';
12
13 export default function createEventResponder<E, C>(
14 displayName: string,
@@ -35,7 +36,10 @@ export default function createEventResponder<E, C>(
36 rootEventTypes: rootEventTypes || null,
37 targetEventTypes: targetEventTypes || null,
38 };
38 - if (__DEV__) {
39 + // We use responder as a Map key later on. When we have a bad
40 + // polyfill, then we can't use it as a key as the polyfill tries
41 + // to add a property to the object.
42 + if (__DEV__ && !hasBadMapPolyfill) {
43 Object.freeze(eventResponder);
44 }
45 return eventResponder;