mirror of
https://github.com/nodejs/node.git
synced 2026-10-14 10:26:26 -04:00
assert,util: fix commutativity edge case
Verify that both objects property keys are enumerable. Fixes: https://github.com/nodejs/node/issues/37710 PR-URL: https://github.com/nodejs/node/pull/37711 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
This commit is contained in:
1 parent
a97f01ea8c
commit
5ff2e582cd
2 files changed
+11
-1
No files matched your search
@@ -282,7 +282,7 @@ function keyCheck(val1, val2, strict, memos, iterationType, aKeys) {
|
||||
// Cheap key test
|
||||
let i = 0;
|
||||
for (; i < aKeys.length; i++) {
|
||||
if (!ObjectPrototypeHasOwnProperty(val2, aKeys[i])) {
|
||||
if (!ObjectPrototypePropertyIsEnumerable(val2, aKeys[i])) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1194,3 +1194,13 @@ assert.throws(
|
||||
Object.setPrototypeOf(b, null);
|
||||
assertNotDeepOrStrict(a, b, assert.AssertionError);
|
||||
}
|
||||
|
||||
{
|
||||
// Verify commutativity
|
||||
// Regression test for https://github.com/nodejs/node/issues/37710
|
||||
const a = { x: 1 };
|
||||
const b = { y: 1 };
|
||||
Object.defineProperty(b, 'x', { value: 1 });
|
||||
|
||||
assertNotDeepOrStrict(a, b);
|
||||
}
|
||||
Reference in new issue
Block a user