Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix deep equal on maps with different structures #2892

Merged
merged 1 commit into from
May 7, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
21 changes: 19 additions & 2 deletions src/structure/immutable/__tests__/deepEqual.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,25 @@ describe('structure.immutable.deepEqual', () => {
}
}), true)
})


it ('should check if key exists on both objects', () => {
testBothWays(fromJS({
a: false
}), fromJS({
b: 1
}), false)
testBothWays(fromJS({
a: ''
}), fromJS({
b: 1
}), false)
testBothWays(fromJS({
a: null
}), fromJS({
b: 1
}), false)
})

it('should treat null and \'\' as equal', () => {
testBothWays(fromJS({
a: {
Expand Down Expand Up @@ -288,4 +306,3 @@ describe('structure.immutable.deepEqual', () => {
}), true)
})
})

2 changes: 1 addition & 1 deletion src/structure/immutable/deepEqual.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const customizer = (obj, other) => {

if (Iterable.isIterable(obj) && Iterable.isIterable(other)) {
return obj.count() === other.count() && obj.every((value, key) => {
return isEqualWith(value, other.get(key), customizer)
return other.has(key) && isEqualWith(value, other.get(key), customizer)
})
}

Expand Down