mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
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:
1 parent
1f5693ec67
commit
835c21a5ef
1 file changed
+13
-1
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user