diff --git a/src/ng/rootScope.js b/src/ng/rootScope.js index c90d28a6cf24..02dbc42cf448 100644 --- a/src/ng/rootScope.js +++ b/src/ng/rootScope.js @@ -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]; } diff --git a/test/ng/rootScopeSpec.js b/test/ng/rootScopeSpec.js index f9cf9412c605..a7522ab0824b 100644 --- a/test/ng/rootScopeSpec.js +++ b/test/ng/rootScopeSpec.js @@ -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 () {