Skip to content

Commit 1007237

Browse files
committed
Ignore $$hashKey in shallowEqual, fix #23
1 parent d49b370 commit 1007237

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

src/utils/shallowEqual.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@
33
return true;
44
}
55

6-
var keysA = Object.keys(objA);
7-
var keysB = Object.keys(objB);
6+
/* $$hashKey is added by angular when using ng-repeat, we ignore that*/
7+
var keysA = Object.keys(objA).filter(k => k !== '$$hashKey');
8+
var keysB = Object.keys(objB).filter(k => k !== '$$hashKey');
89

910
if (keysA.length !== keysB.length) {
1011
return false;

test/utils/shallowEqual.spec.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,5 +53,14 @@ describe('Utils', () => {
5353
)
5454
).toBe(false);
5555
});
56+
57+
it('Should ignore $$hashKey property if present', () => {
58+
expect(
59+
shallowEqual(
60+
{ a: 1, b: 2, c: undefined, $$hashKey: 1 },
61+
{ a: 1, b: 2, c: undefined }
62+
)
63+
).toBe(true);
64+
});
5665
});
5766
});

0 commit comments

Comments
 (0)