Repository navigation
Commit 62be736
🐞 fix(deepEqual): empty array and empty plain object should not be equal (#13533)
* fix(deepEqual): empty array and empty plain object should not be equal
deepEqual([], {}) and deepEqual({}, []) incorrectly returned true because
both have zero enumerable keys and neither triggered the
isEmptyObjectWithCustomPrototype guard ([] is excluded by Array.isArray
and {} is excluded by isPlainObject).
Add an early-return check: when both objects have zero keys and their
array-ness differs, return false. This preserves the intentional
sparse-array / plain-object compatibility introduced in #13347 (only
non-empty containers need that treatment) while fixing the degenerate
empty case.
Fixes: deepEqual([], {}) => false (was true)
Fixes: deepEqual({ items: [] }, { items: {} }) => false (was true)
* Update src/utils/deepEqual.ts
---------
Co-authored-by: JSap0914 <[email protected]>
Co-authored-by: Bill <[email protected]>1 parent cee92e2 commit 62be736
2 files changed
Lines changed: 11 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
223 | 223 | | |
224 | 224 | | |
225 | 225 | | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
226 | 233 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
40 | 44 | | |
41 | 45 | | |
42 | 46 | | |
| |||
0 commit comments