Skip to content

Commit 64b13ad

Browse files
committed
Return empty array for Object.getOwnPropertySymbols if it doesn't exist
1 parent 5489eaf commit 64b13ad

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

internal/util/comparisons.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
const regexFlagsSupported = /a/g.flags !== undefined;
77

88
const objectIs = Object.is ? Object.is : require('object-is');
9+
const objectGetOwnPropertySymbols = Object.getOwnPropertySymbols ? Object.getOwnPropertySymbols : () => [];
910

1011
function uncurryThis(f) {
1112
return f.call.bind(f);
@@ -50,7 +51,7 @@ function getOwnNonIndexProperties(value) {
5051
return Object.keys(value)
5152
.filter(isNonIndex)
5253
.concat(
53-
Object.getOwnPropertySymbols(value)
54+
objectGetOwnPropertySymbols(value)
5455
.filter(Object.prototype.propertyIsEnumerable.bind(value))
5556
);
5657
}
@@ -273,7 +274,7 @@ function keyCheck(val1, val2, strict, memos, iterationType, aKeys) {
273274
}
274275

275276
if (strict && arguments.length === 5) {
276-
const symbolKeysA = Object.getOwnPropertySymbols(val1);
277+
const symbolKeysA = objectGetOwnPropertySymbols(val1);
277278
if (symbolKeysA.length !== 0) {
278279
let count = 0;
279280
for (i = 0; i < symbolKeysA.length; i++) {
@@ -288,13 +289,13 @@ function keyCheck(val1, val2, strict, memos, iterationType, aKeys) {
288289
return false;
289290
}
290291
}
291-
const symbolKeysB = Object.getOwnPropertySymbols(val2);
292+
const symbolKeysB = objectGetOwnPropertySymbols(val2);
292293
if (symbolKeysA.length !== symbolKeysB.length &&
293294
getEnumerables(val2, symbolKeysB).length !== count) {
294295
return false;
295296
}
296297
} else {
297-
const symbolKeysB = Object.getOwnPropertySymbols(val2);
298+
const symbolKeysB = objectGetOwnPropertySymbols(val2);
298299
if (symbolKeysB.length !== 0 &&
299300
getEnumerables(val2, symbolKeysB).length !== 0) {
300301
return false;

0 commit comments

Comments
 (0)