Skip to content

Commit dc0c5bc

Browse files
lib: refine keyCheck mode condition for strict comparisons
1 parent 1532570 commit dc0c5bc

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

lib/assert.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,10 @@ Assert.prototype.deepStrictEqual = function deepStrictEqual(actual, expected, me
313313
throw new ERR_MISSING_ARGS('actual', 'expected');
314314
}
315315
if (isDeepEqual === undefined) lazyLoadComparison();
316-
if (!isDeepStrictEqual(actual, expected, { __proto__: null, skipPrototypeComparison: this?.[kOptions]?.skipPrototypeComparison })) {
316+
if (!isDeepStrictEqual(actual, expected, {
317+
__proto__: null,
318+
skipPrototypeComparison: this?.[kOptions]?.skipPrototypeComparison,
319+
})) {
317320
innerFail({
318321
actual,
319322
expected,
@@ -339,7 +342,10 @@ function notDeepStrictEqual(actual, expected, message) {
339342
throw new ERR_MISSING_ARGS('actual', 'expected');
340343
}
341344
if (isDeepEqual === undefined) lazyLoadComparison();
342-
if (isDeepStrictEqual(actual, expected, { __proto__: null, skipPrototypeComparison: this?.[kOptions]?.skipPrototypeComparison })) {
345+
if (isDeepStrictEqual(actual, expected, {
346+
__proto__: null,
347+
skipPrototypeComparison: this?.[kOptions]?.skipPrototypeComparison,
348+
})) {
343349
innerFail({
344350
actual,
345351
expected,

lib/internal/util/comparisons.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -459,7 +459,7 @@ function keyCheck(val1, val2, mode, memos, iterationType, keys2) {
459459
}
460460
} else if (keys2.length !== (keys1 = ObjectKeys(val1)).length) {
461461
return false;
462-
} else if (mode >= kStrict) {
462+
} else if (mode === kStrict || mode === kStrictWithoutPrototypes) {
463463
const symbolKeysA = getOwnSymbols(val1);
464464
if (symbolKeysA.length !== 0) {
465465
let count = 0;

0 commit comments

Comments
 (0)