Skip to content

Commit

Permalink
add a workaround for IE11 crash, fix #485
Browse files Browse the repository at this point in the history
  • Loading branch information
zloirock committed Feb 6, 2019
1 parent 3fb5e27 commit 75ca2ae
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 4 deletions.
1 change: 1 addition & 0 deletions modules/_function-to-string.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require('./_shared')('native-function-to-string', Function.toString);
4 changes: 4 additions & 0 deletions modules/_native-weak-map.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
var nativeFunctionToString = require('./_function-to-string');
var WeakMap = require('./_global').WeakMap;

module.exports = typeof WeakMap === 'function' && /native code/.test(nativeFunctionToString.call(WeakMap));
2 changes: 1 addition & 1 deletion modules/_redefine.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ var global = require('./_global');
var hide = require('./_hide');
var has = require('./_has');
var SRC = require('./_uid')('src');
var $toString = require('./_function-to-string');
var TO_STRING = 'toString';
var $toString = Function[TO_STRING];
var TPL = ('' + $toString).split(TO_STRING);

require('./_core').inspectSource = function (it) {
Expand Down
7 changes: 4 additions & 3 deletions modules/es6.weak-map.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
'use strict';
var global = require('./_global');
var each = require('./_array-methods')(0);
var redefine = require('./_redefine');
var meta = require('./_meta');
var assign = require('./_object-assign');
var weak = require('./_collection-weak');
var isObject = require('./_is-object');
var fails = require('./_fails');
var validate = require('./_validate-collection');
var NATIVE_WEAK_MAP = require('./_validate-collection');
var IS_IE11 = !global.ActiveXObject && 'ActiveXObject' in global;
var WEAK_MAP = 'WeakMap';
var getWeak = meta.getWeak;
var isExtensible = Object.isExtensible;
var uncaughtFrozenStore = weak.ufstore;
var tmp = {};
var InternalMap;

var wrapper = function (get) {
Expand Down Expand Up @@ -39,7 +40,7 @@ var methods = {
var $WeakMap = module.exports = require('./_collection')(WEAK_MAP, wrapper, methods, weak, true, true);

// IE11 WeakMap frozen keys fix
if (fails(function () { return new $WeakMap().set((Object.freeze || Object)(tmp), 7).get(tmp) != 7; })) {
if (NATIVE_WEAK_MAP && IS_IE11) {
InternalMap = weak.getConstructor(wrapper, WEAK_MAP);
assign(InternalMap.prototype, methods);
meta.NEED = true;
Expand Down

0 comments on commit 75ca2ae

Please sign in to comment.