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

This commit is contained in:
Dominic Gannaway
2019-07-29 21:16:30 +01:00
committed by GitHub
parent 47656bf2a1
commit 55bc393f72
+5 -1
View File
@@ -8,6 +8,7 @@
import type {ReactEventResponder} from 'shared/ReactTypes';
import {REACT_RESPONDER_TYPE} from 'shared/ReactSymbols';
import {hasBadMapPolyfill} from './hasBadMapPolyfill';
export default function createEventResponder<E, C>(
displayName: string,
@@ -35,7 +36,10 @@ export default function createEventResponder<E, C>(
rootEventTypes: rootEventTypes || null,
targetEventTypes: targetEventTypes || null,
};
if (__DEV__) {
// We use responder as a Map key later on. When we have a bad
// polyfill, then we can't use it as a key as the polyfill tries
// to add a property to the object.
if (__DEV__ && !hasBadMapPolyfill) {
Object.freeze(eventResponder);
}
return eventResponder;