Skip to content
This repository has been archived by the owner on Apr 12, 2024. It is now read-only.

fix(Angular): Infinite $digest Loop occur when using deep $watch on an o... #8715

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/Angular.js
Original file line number Diff line number Diff line change
Expand Up @@ -895,7 +895,8 @@ function equals(o1, o2) {
return true;
}
} else if (isDate(o1)) {
return isDate(o2) && o1.getTime() == o2.getTime();
if (!isDate(o2)) return false;
return (isNaN(o1.getTime()) && isNaN(o2.getTime())) || (o1.getTime() === o2.getTime());
} else if (isRegExp(o1) && isRegExp(o2)) {
return o1.toString() == o2.toString();
} else {
Expand Down
5 changes: 5 additions & 0 deletions test/AngularSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,11 @@ describe('angular', function() {
expect(equals(new Date(0), new Date(1))).toBe(false);
expect(equals(new Date(0), 0)).toBe(false);
expect(equals(0, new Date(0))).toBe(false);

expect(equals(new Date(undefined), new Date(undefined))).toBe(true);
expect(equals(new Date(undefined), new Date(0))).toBe(false);
expect(equals(new Date(undefined), new Date(null))).toBe(false);
expect(equals(new Date(undefined), new Date('wrong'))).toBe(true);
});

it('should correctly test for keys that are present on Object.prototype', function() {
Expand Down