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

Commit ffa8441

Browse files
committed
bug(equals): incorect comparison of dates
1 parent 5d8528c commit ffa8441

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

src/Angular.js

+2
Original file line numberDiff line numberDiff line change
@@ -671,6 +671,8 @@ function equals(o1, o2) {
671671
}
672672
return true;
673673
}
674+
} else if (isDate(o1)) {
675+
return isDate(o2) && o1.getTime() == o2.getTime();
674676
} else {
675677
if (isScope(o1) || isScope(o2) || isWindow(o1) || isWindow(o2)) return false;
676678
keySet = {};

test/AngularSpec.js

+7
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,13 @@ describe('angular', function() {
168168
expect(equals(window, window.parent)).toBe(false);
169169
expect(equals(window, undefined)).toBe(false);
170170
});
171+
172+
it('should compare dates', function() {
173+
expect(equals(new Date(0), new Date(0))).toBe(true);
174+
expect(equals(new Date(0), new Date(1))).toBe(false);
175+
expect(equals(new Date(0), 0)).toBe(false);
176+
expect(equals(0, new Date(0))).toBe(false);
177+
});
171178
});
172179

173180
describe('size', function() {

0 commit comments

Comments
 (0)