diff options
| author | Sekib Omazic | 2014-02-09 17:58:11 +0100 | 
|---|---|---|
| committer | Jeff Cross | 2014-03-19 11:34:15 -0700 | 
| commit | fb6062fb9d83545730b993e94ac7482ffd43a62c (patch) | |
| tree | bec315cab78abd62baa518f3c46013825f56bbd0 /test/ng | |
| parent | 0c65f1ae3e86cd3eed078df4e691402d591cc757 (diff) | |
| download | angular.js-fb6062fb9d83545730b993e94ac7482ffd43a62c.tar.bz2 | |
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
Diffstat (limited to 'test/ng')
| -rw-r--r-- | test/ng/rootScopeSpec.js | 4 | 
1 files changed, 4 insertions, 0 deletions
| diff --git a/test/ng/rootScopeSpec.js b/test/ng/rootScopeSpec.js index 251a8ce8..2ea41489 100644 --- a/test/ng/rootScopeSpec.js +++ b/test/ng/rootScopeSpec.js @@ -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 = []; | 
