Skip to content

Commit 2cc1988

Browse files
authored
fix(shallow): undefined value (#3205)
* add failing test * check with .has
1 parent c4085a4 commit 2cc1988

2 files changed

Lines changed: 5 additions & 1 deletion

File tree

src/vanilla/shallow.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ const compareEntries = (
1919
return false
2020
}
2121
for (const [key, value] of mapA) {
22-
if (!Object.is(value, mapB.get(key))) {
22+
if (!mapB.has(key) || !Object.is(value, mapB.get(key))) {
2323
return false
2424
}
2525
}

tests/vanilla/shallow.test.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,10 @@ describe('shallow', () => {
170170
const arr = [1, 2]
171171
expect(shallow([arr, 1], [arr, 1])).toBe(true)
172172
})
173+
174+
it('should work with undefined (#3204)', () => {
175+
expect(shallow({ a: undefined }, { b: 1 })).toBe(false)
176+
})
173177
})
174178

175179
describe('mixed cases', () => {

0 commit comments

Comments
 (0)