Skip to content

Commit

Permalink
fix #736
Browse files Browse the repository at this point in the history
  • Loading branch information
zloirock committed Dec 23, 2019
1 parent f54526f commit 8b9f774
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
2 changes: 1 addition & 1 deletion packages/core-js/internals/use-symbol-as-uid.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ module.exports = NATIVE_SYMBOL
// eslint-disable-next-line no-undef
&& !Symbol.sham
// eslint-disable-next-line no-undef
&& typeof Symbol() == 'symbol';
&& typeof Symbol.iterator == 'symbol';
2 changes: 1 addition & 1 deletion packages/core-js/internals/well-known-symbol.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ var USE_SYMBOL_AS_UID = require('../internals/use-symbol-as-uid');

var WellKnownSymbolsStore = shared('wks');
var Symbol = global.Symbol;
var createWellKnownSymbol = USE_SYMBOL_AS_UID ? Symbol : uid;
var createWellKnownSymbol = USE_SYMBOL_AS_UID ? Symbol : Symbol && Symbol.withoutSetter || uid;

module.exports = function (name) {
if (!has(WellKnownSymbolsStore, name)) {
Expand Down
16 changes: 9 additions & 7 deletions packages/core-js/modules/es.symbol.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ var wrap = function (tag, description) {
return symbol;
};

var isSymbol = NATIVE_SYMBOL && typeof $Symbol.iterator == 'symbol' ? function (it) {
var isSymbol = USE_SYMBOL_AS_UID ? function (it) {
return typeof it == 'symbol';
} : function (it) {
return Object(it) instanceof $Symbol;
Expand Down Expand Up @@ -178,12 +178,20 @@ if (!NATIVE_SYMBOL) {
return getInternalState(this).tag;
});

redefine($Symbol, 'withoutSetter', function (description) {

This comment has been minimized.

Copy link
@JakeChampion

JakeChampion Dec 23, 2019

Contributor

Is this making a new property on the Symbol constructor called withoutSetter? Is that a spec proposal?

This comment has been minimized.

Copy link
@zloirock

zloirock Dec 23, 2019

Author Owner

It's not a spec proposal. It's a workaround for several issues related to exotic environments objects with non-standard [[DefineOwnProperty]] / [[Set]], well-known symbols and multiple core-js copies. Maybe it will be moved to the internal store, however, I'm not sure about it.

return wrap(uid(description), description);
});

propertyIsEnumerableModule.f = $propertyIsEnumerable;
definePropertyModule.f = $defineProperty;
getOwnPropertyDescriptorModule.f = $getOwnPropertyDescriptor;
getOwnPropertyNamesModule.f = getOwnPropertyNamesExternal.f = $getOwnPropertyNames;
getOwnPropertySymbolsModule.f = $getOwnPropertySymbols;

wrappedWellKnownSymbolModule.f = function (name) {
return wrap(wellKnownSymbol(name), name);
};

if (DESCRIPTORS) {
// https://github.com/tc39/proposal-Symbol-description
nativeDefineProperty($Symbol[PROTOTYPE], 'description', {
Expand All @@ -198,12 +206,6 @@ if (!NATIVE_SYMBOL) {
}
}

if (!USE_SYMBOL_AS_UID) {
wrappedWellKnownSymbolModule.f = function (name) {
return wrap(wellKnownSymbol(name), name);
};
}

$({ global: true, wrap: true, forced: !NATIVE_SYMBOL, sham: !NATIVE_SYMBOL }, {
Symbol: $Symbol
});
Expand Down

0 comments on commit 8b9f774

Please sign in to comment.