aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIgor Minar2011-11-29 16:54:25 -0500
committerIgor Minar2011-11-30 14:49:35 -0500
commitb00da987a9e0e4378d8252add8e15ad2e508901d (patch)
tree568629de5e9200075d9b138773c3ec4c2f562c2f
parent188bdf7768c9594a01a18abae3fa9a3114802508 (diff)
downloadangular.js-b00da987a9e0e4378d8252add8e15ad2e508901d.tar.bz2
scope($digest): add new&old val to the infinite $digest log
-rw-r--r--src/service/scope.js16
-rw-r--r--test/service/scopeSpec.js6
2 files changed, 14 insertions, 8 deletions
diff --git a/src/service/scope.js b/src/service/scope.js
index d6cf60c9..dba4de1d 100644
--- a/src/service/scope.js
+++ b/src/service/scope.js
@@ -323,7 +323,8 @@ function $RootScopeProvider(){
length,
dirty, ttl = 100,
next, current, target = this,
- watchLog = [];
+ watchLog = [],
+ logIdx, logMsg;
if (target.$$phase) {
throw Error(target.$$phase + ' already in progress');
@@ -355,12 +356,13 @@ function $RootScopeProvider(){
watch.last = copy(value);
watch.fn(current, value, ((last === initWatchVal) ? value : last));
if (ttl < 5) {
- if (!watchLog[4-ttl]) watchLog[4-ttl] = [];
- if (isFunction(watch.exp)) {
- watchLog[4-ttl].push('fn: ' + (watch.exp.name || watch.exp.toString()));
- } else {
- watchLog[4-ttl].push(watch.exp);
- }
+ logIdx = 4-ttl;
+ if (!watchLog[logIdx]) watchLog[logIdx] = [];
+ logMsg = (isFunction(watch.exp))
+ ? 'fn: ' + (watch.exp.name || watch.exp.toString())
+ : watch.exp;
+ logMsg += '; newVal: ' + toJson(value) + '; oldVal: ' + toJson(last);
+ watchLog[logIdx].push(logMsg);
}
}
} catch (e) {
diff --git a/test/service/scopeSpec.js b/test/service/scopeSpec.js
index 6e8d78ff..47c5f889 100644
--- a/test/service/scopeSpec.js
+++ b/test/service/scopeSpec.js
@@ -216,7 +216,11 @@ describe('Scope', function() {
$rootScope.$digest();
}).toThrow('100 $digest() iterations reached. Aborting!\n'+
'Watchers fired in the last 5 iterations: ' +
- '[["a","b"],["a","b"],["a","b"],["a","b"],["a","b"]]');
+ '[["a; newVal: 96; oldVal: 95","b; newVal: 97; oldVal: 96"],' +
+ '["a; newVal: 97; oldVal: 96","b; newVal: 98; oldVal: 97"],' +
+ '["a; newVal: 98; oldVal: 97","b; newVal: 99; oldVal: 98"],' +
+ '["a; newVal: 99; oldVal: 98","b; newVal: 100; oldVal: 99"],' +
+ '["a; newVal: 100; oldVal: 99","b; newVal: 101; oldVal: 100"]]');
}));