diff --git a/src/ng/rootScope.js b/src/ng/rootScope.js index ce0f8ad54cb3..dbb93000cd72 100644 --- a/src/ng/rootScope.js +++ b/src/ng/rootScope.js @@ -453,7 +453,9 @@ 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]; } diff --git a/test/ng/rootScopeSpec.js b/test/ng/rootScopeSpec.js index 251a8ce882c4..2ea414893032 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 = [];