Skip to content
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
@runtarm

Description

@runtarm

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

These issues might be related: #657 #4605

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions