| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 9cd9aa8 commit 764b13d
3 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -636,7 +636,8 @@ are also recursively evaluated by the following rules. | |||
| 636 | 636 | * Implementation does not test the [`[[Prototype]]`][prototype-spec] of | |
| 637 | 637 | objects. | |
| 638 | 638 | * [`Symbol`][] properties are not compared. | |
| 639 | - * [`WeakMap`][] and [`WeakSet`][] comparison does not rely on their values. | ||
| 639 | + * [`WeakMap`][] and [`WeakSet`][] comparison does not rely on their values | ||
| 640 | + but only on their instances. | ||
| 640 | 641 | * [`RegExp`][] lastIndex, flags, and source are always compared, even if these | |
| 641 | 642 | are not enumerable properties. | |
| 642 | 643 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -46,6 +46,8 @@ const { | |||
| 46 | 46 | isFloat64Array, | |
| 47 | 47 | isKeyObject, | |
| 48 | 48 | isCryptoKey, | |
| 49 | + isWeakMap, | ||
| 50 | + isWeakSet, | ||
| 49 | 51 | } = types; | |
| 50 | 52 | const { | |
| 51 | 53 | constants: { | |
@@ -283,7 +285,10 @@ function innerDeepEqual(val1, val2, strict, memos) { | |||
| 283 | 285 | ) { | |
| 284 | 286 | return false; | |
| 285 | 287 | } | |
| 288 | + } else if (isWeakMap(val1) || isWeakSet(val1)) { | ||
| 289 | + return false; | ||
| 286 | 290 | } | |
| 291 | + | ||
| 287 | 292 | return keyCheck(val1, val2, strict, memos, kNoIterator); | |
| 288 | 293 | } | |
| 289 | 294 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1304,3 +1304,35 @@ if (common.hasCrypto) { | |||
| 1304 | 1304 | } | |
| 1305 | 1305 | })().then(common.mustCall()); | |
| 1306 | 1306 | } | |
| 1307 | + | ||
| 1308 | + // Comparing two identical WeakMap instances | ||
| 1309 | + { | ||
| 1310 | + const weakMap = new WeakMap(); | ||
| 1311 | + assertDeepAndStrictEqual(weakMap, weakMap); | ||
| 1312 | + } | ||
| 1313 | + | ||
| 1314 | + // Comparing two different WeakMap instances | ||
| 1315 | + { | ||
| 1316 | + const weakMap1 = new WeakMap(); | ||
| 1317 | + const objA = {}; | ||
| 1318 | + weakMap1.set(objA, 'ok'); | ||
| 1319 | + | ||
| 1320 | + const weakMap2 = new WeakMap(); | ||
| 1321 | + const objB = {}; | ||
| 1322 | + weakMap2.set(objB, 'ok'); | ||
| 1323 | + | ||
| 1324 | + assertNotDeepOrStrict(weakMap1, weakMap2); | ||
| 1325 | + } | ||
| 1326 | + | ||
| 1327 | + // Comparing two identical WeakSet instances | ||
| 1328 | + { | ||
| 1329 | + const weakSet = new WeakSet(); | ||
| 1330 | + assertDeepAndStrictEqual(weakSet, weakSet); | ||
| 1331 | + } | ||
| 1332 | + | ||
| 1333 | + // Comparing two different WeakSet instances | ||
| 1334 | + { | ||
| 1335 | + const weakSet1 = new WeakSet(); | ||
| 1336 | + const weakSet2 = new WeakSet(); | ||
| 1337 | + assertNotDeepOrStrict(weakSet1, weakSet2); | ||
| 1338 | + } | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments