Skip to content

Commit 61ebde0

Browse files
committed
use hasOwn instead of in in some required cases
1 parent e41af69 commit 61ebde0

File tree

3 files changed

+12
-7
lines changed

3 files changed

+12
-7
lines changed

packages/core-js/internals/function-bind.js

+6-4
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ var global = require('../internals/global');
33
var uncurryThis = require('../internals/function-uncurry-this');
44
var aCallable = require('../internals/a-callable');
55
var isObject = require('../internals/is-object');
6+
var hasOwn = require('../internals/has-own-property');
67
var arraySlice = require('../internals/array-slice');
78

89
var Function = global.Function;
@@ -11,7 +12,7 @@ var join = uncurryThis([].join);
1112
var factories = {};
1213

1314
var construct = function (C, argsLength, args) {
14-
if (!(argsLength in factories)) {
15+
if (!hasOwn(factories, argsLength)) {
1516
for (var list = [], i = 0; i < argsLength; i++) list[i] = 'a[' + i + ']';
1617
factories[argsLength] = Function('C,a', 'return new C(' + join(list, ',') + ')');
1718
} return factories[argsLength](C, args);
@@ -20,12 +21,13 @@ var construct = function (C, argsLength, args) {
2021
// `Function.prototype.bind` method implementation
2122
// https://tc39.es/ecma262/#sec-function.prototype.bind
2223
module.exports = Function.bind || function bind(that /* , ...args */) {
23-
var fn = aCallable(this);
24+
var F = aCallable(this);
25+
var Prototype = F.prototype;
2426
var partArgs = arraySlice(arguments, 1);
2527
var boundFunction = function bound(/* args... */) {
2628
var args = concat(partArgs, arraySlice(arguments));
27-
return this instanceof boundFunction ? construct(fn, args.length, args) : fn.apply(that, args);
29+
return this instanceof boundFunction ? construct(F, args.length, args) : F.apply(that, args);
2830
};
29-
if (isObject(fn.prototype)) boundFunction.prototype = fn.prototype;
31+
if (isObject(Prototype)) boundFunction.prototype = Prototype;
3032
return boundFunction;
3133
};

packages/core-js/modules/es.date.to-primitive.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
var hasOwn = require('../internals/has-own-property');
12
var redefine = require('../internals/redefine');
23
var dateToPrimitive = require('../internals/date-to-primitive');
34
var wellKnownSymbol = require('../internals/well-known-symbol');
@@ -7,6 +8,6 @@ var DatePrototype = Date.prototype;
78

89
// `Date.prototype[@@toPrimitive]` method
910
// https://tc39.es/ecma262/#sec-date.prototype-@@toprimitive
10-
if (!(TO_PRIMITIVE in DatePrototype)) {
11+
if (!hasOwn(DatePrototype, TO_PRIMITIVE)) {
1112
redefine(DatePrototype, TO_PRIMITIVE, dateToPrimitive);
1213
}

packages/core-js/modules/es.symbol.description.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@ var defineProperty = require('../internals/object-define-property').f;
1313
var copyConstructorProperties = require('../internals/copy-constructor-properties');
1414

1515
var NativeSymbol = global.Symbol;
16+
var SymbolPrototype = NativeSymbol && NativeSymbol.prototype;
1617

17-
if (DESCRIPTORS && isCallable(NativeSymbol) && (!('description' in NativeSymbol.prototype) ||
18+
if (DESCRIPTORS && isCallable(NativeSymbol) && (!('description' in SymbolPrototype) ||
1819
// Safari 12 bug
1920
NativeSymbol().description !== undefined
2021
)) {
@@ -29,8 +30,9 @@ if (DESCRIPTORS && isCallable(NativeSymbol) && (!('description' in NativeSymbol.
2930
if (description === '') EmptyStringDescriptionStore[result] = true;
3031
return result;
3132
};
33+
3234
copyConstructorProperties(SymbolWrapper, NativeSymbol);
33-
var SymbolPrototype = SymbolWrapper.prototype = NativeSymbol.prototype;
35+
SymbolWrapper.prototype = SymbolPrototype;
3436
SymbolPrototype.constructor = SymbolWrapper;
3537

3638
var NATIVE_SYMBOL = String(NativeSymbol('test')) == 'Symbol(test)';

0 commit comments

Comments
 (0)