aboutsummaryrefslogtreecommitdiffstats
path: root/src/ng/rootScope.js
diff options
context:
space:
mode:
authorSekib Omazic2014-02-09 17:58:11 +0100
committerJeff Cross2014-03-19 11:34:15 -0700
commitfb6062fb9d83545730b993e94ac7482ffd43a62c (patch)
treebec315cab78abd62baa518f3c46013825f56bbd0 /src/ng/rootScope.js
parent0c65f1ae3e86cd3eed078df4e691402d591cc757 (diff)
downloadangular.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 'src/ng/rootScope.js')
-rw-r--r--src/ng/rootScope.js4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/ng/rootScope.js b/src/ng/rootScope.js
index ce0f8ad5..dbb93000 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];
}