diff --git a/Libraries/Core/__tests__/MapAndSetPolyfills-test.js b/Libraries/Core/__tests__/MapAndSetPolyfills-test.js index 79a73a96878..cfda89e12d9 100644 --- a/Libraries/Core/__tests__/MapAndSetPolyfills-test.js +++ b/Libraries/Core/__tests__/MapAndSetPolyfills-test.js @@ -14,8 +14,6 @@ const {freeze, seal, preventExtensions} = Object; function setup() { jest.setMock('../../vendor/core/_shouldPolyfillES6Collection', () => true); - jest.unmock('_wrapObjectFreezeAndFriends'); - require('_wrapObjectFreezeAndFriends'); } function cleanup() { diff --git a/Libraries/Core/polyfillES6Collections.js b/Libraries/Core/polyfillES6Collections.js index afbb24ab23b..ca1ee798c73 100644 --- a/Libraries/Core/polyfillES6Collections.js +++ b/Libraries/Core/polyfillES6Collections.js @@ -18,10 +18,8 @@ const {polyfillGlobal} = require('PolyfillFunctions'); */ const _shouldPolyfillCollection = require('_shouldPolyfillES6Collection'); if (_shouldPolyfillCollection('Map')) { - require('_wrapObjectFreezeAndFriends'); polyfillGlobal('Map', () => require('Map')); } if (_shouldPolyfillCollection('Set')) { - require('_wrapObjectFreezeAndFriends'); polyfillGlobal('Set', () => require('Set')); } diff --git a/Libraries/vendor/core/Map.js b/Libraries/vendor/core/Map.js index 009a5258dcb..76f27534ac6 100644 --- a/Libraries/vendor/core/Map.js +++ b/Libraries/vendor/core/Map.js @@ -26,9 +26,6 @@ module.exports = (function(global, undefined) { return global.Map; } - // In case this module has not already been evaluated, import it now. - require('./_wrapObjectFreezeAndFriends'); - const hasOwn = Object.prototype.hasOwnProperty; /** diff --git a/Libraries/vendor/core/_wrapObjectFreezeAndFriends.js b/Libraries/vendor/core/_wrapObjectFreezeAndFriends.js deleted file mode 100644 index 9bfadc9adf0..00000000000 --- a/Libraries/vendor/core/_wrapObjectFreezeAndFriends.js +++ /dev/null @@ -1,39 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - * @author Ben Newman (@benjamn) - * @flow - * @format - */ - -'use strict'; - -let testMap; // Initialized lazily. -function getTestMap() { - return testMap || (testMap = new (require('./Map'))()); -} - -// Wrap Object.{freeze,seal,preventExtensions} so each function adds its -// argument to a Map first, which gives our ./Map.js polyfill a chance to -// tag the object before it becomes non-extensible. -['freeze', 'seal', 'preventExtensions'].forEach(name => { - const method = Object[name]; - if (typeof method === 'function') { - (Object: any)[name] = function(obj) { - try { - // If .set succeeds, also call .delete to avoid leaking memory. - getTestMap() - .set(obj, obj) - .delete(obj); - } finally { - // If .set fails, the exception will be silently swallowed - // by this return-from-finally statement, and the method will - // behave exactly as it did before it was wrapped. - return method.call(Object, obj); - } - }; - } -});