Don't prevent extensions on Fiber if using bad Map polyfill (#9572)

Many Map polyfills work by adding an extra field to the key type.

In the future, we'll likely print a warning.
This commit is contained in:
Andrew Clark authored and GitHub committed 2017-05-01 13:23:37 -07:00
1 parent 1f5693ec67
commit 835c21a5ef
1 file changed
+13 -1
+13 -1
View File
@@ -49,6 +49,18 @@ var invariant = require('fbjs/lib/invariant');
if (__DEV__) {
var getComponentName = require('getComponentName');
var hasBadMapPolyfill = false;
try {
const nonExtensibleObject = Object.preventExtensions({});
/* eslint-disable no-new */
new Map([[nonExtensibleObject, null]]);
new Set([nonExtensibleObject]);
/* eslint-enable no-new */
} catch (e) {
// TODO: Consider warning about bad polyfills
hasBadMapPolyfill = true;
}
}
// A Fiber is work on a Component that needs to be done or was done. There can
@@ -234,7 +246,7 @@ var createFiber = function(
fiber._debugSource = null;
fiber._debugOwner = null;
fiber._debugIsCurrentlyTiming = false;
if (typeof Object.preventExtensions === 'function') {
if (!hasBadMapPolyfill && typeof Object.preventExtensions === 'function') {
Object.preventExtensions(fiber);
}
}