bug(equals): incorect comparison of dates

This commit is contained in:
Misko Hevery 2012-02-23 13:57:28 -08:00
parent 5d8528cc2e
commit ffa8441886
2 changed files with 9 additions and 0 deletions

View file

@ -671,6 +671,8 @@ function equals(o1, o2) {
}
return true;
}
} else if (isDate(o1)) {
return isDate(o2) && o1.getTime() == o2.getTime();
} else {
if (isScope(o1) || isScope(o2) || isWindow(o1) || isWindow(o2)) return false;
keySet = {};

View file

@ -168,6 +168,13 @@ describe('angular', function() {
expect(equals(window, window.parent)).toBe(false);
expect(equals(window, undefined)).toBe(false);
});
it('should compare dates', function() {
expect(equals(new Date(0), new Date(0))).toBe(true);
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);
});
});
describe('size', function() {