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

fix($rootScope): ng-repeat can't handle NaN values. #4605 #6192

Closed
wants to merge 2 commits 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/ng/rootScope.js
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,8 @@ function $RootScopeProvider(){
}
// copy the items to oldValue and look for changes.
for (var i = 0; i < newLength; i++) {
if (oldValue[i] !== newValue[i]) {
var bothNaN = (oldValue[i] !== oldValue[i]) && (newValue[i] !== newValue[i]);
if (!bothNaN && (oldValue[i] !== newValue[i])) {
changeDetected++;
oldValue[i] = newValue[i];
}
Expand Down
5 changes: 5 additions & 0 deletions test/ng/rootScopeSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -579,6 +579,11 @@ describe('Scope', function() {
log = [];
$rootScope.$digest();
expect(log).toEqual([ '[{},[]]' ]);

log = [];
$rootScope.obj[0] = NaN;
$rootScope.$digest();
expect(isNaN(log.shift())).toBe(true); //jasmine's toBe and toEqual don't work well with NaNs
});

it('should watch array-like objects like arrays', function () {
Expand Down