This repository was archived by the owner on Apr 12, 2024. It is now read-only.
This repository was archived by the owner on Apr 12, 2024. It is now read-only.
Infinite $digest Loop occur when using deep $watch on an object that contains an "Invalid Date". #8650
Closed
Description
Code to reproduce:
$scope.items = { date: new Date(undefined) };
$scope.$watch('items', angular.noop, true);
Plunker: http://plnkr.co/edit/jsb1nVTHMmi6ynnnlHTS?p=preview
This is probably because angular.equals
use .getTime()
to compare Date objects: Angular.js#L910.
return isDate(o2) && o1.getTime() == o2.getTime();
But .getTime()
return NaN
for an invalid Date object.
var invalidDate = new Date(undefined);
invalidDate.toString(); // return "Invalid Date"
invalidDate.getTime(); // return NaN