mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
Merge pull request #3370 from varunrau/master
Fixed shallowEqual for arguments that are not objects
This commit is contained in:
commit
5afa657d77
2 files changed
+22
No files matched your search
@@ -41,6 +41,24 @@ describe('shallowEqual', function() {
|
||||
).toBe(true);
|
||||
});
|
||||
|
||||
it('returns false if arguments are not objects and not equal', function() {
|
||||
expect(
|
||||
shallowEqual(
|
||||
1,
|
||||
2
|
||||
)
|
||||
).toBe(false);
|
||||
});
|
||||
|
||||
it('returns false if only one argument is not an object', function() {
|
||||
expect(
|
||||
shallowEqual(
|
||||
1,
|
||||
{}
|
||||
)
|
||||
).toBe(false);
|
||||
})
|
||||
|
||||
it('returns false if first argument has too many keys', function() {
|
||||
expect(
|
||||
shallowEqual(
|
||||
|
||||
@@ -27,6 +27,10 @@ function shallowEqual(objA, objB) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (typeof objA !== 'object' || typeof objB !== 'object') {
|
||||
return false;
|
||||
}
|
||||
|
||||
var key;
|
||||
// Test for A's keys different from B.
|
||||
for (key in objA) {
|
||||
|
||||
Reference in new issue
Block a user