mirror of
https://github.com/zhigang1992/angular.js.git
synced 2026-04-24 12:05:46 +08:00
fix($rootScope): ng-repeat can't handle NaN values. #4605
$watchCollection checks if oldValue !== newValue which does not work for NaN. This was causing infinite digest errors, since comparing NaN to NaN in $watchCollection would always return false, indicating that a change was occuring on each loop. This fix adds a simple check to see if the current value and previous value are both NaN, and if so, does not count it as a change. Closes #4605
This commit is contained in:
committed by
Tobias Bosch
parent
10d3e1e447
commit
e48c28fe92
@@ -603,6 +603,10 @@ describe('Scope', function() {
|
||||
expect(log.empty()).toEqual([{newVal: [{}, []], oldVal: ['b', {}, []]}]);
|
||||
});
|
||||
|
||||
it('should not infinitely digest when current value is NaN', function() {
|
||||
$rootScope.obj = [NaN];
|
||||
$rootScope.$digest();
|
||||
});
|
||||
|
||||
it('should watch array-like objects like arrays', function () {
|
||||
var arrayLikelog = [];
|
||||
|
||||
Reference in New Issue
Block a user