fix(scope): rerun $digest from root, rather then per scope.

This commit is contained in:
Misko Hevery
2011-08-11 15:02:08 -07:00
parent 8bc7beacd8
commit 1c9fc1e1de
2 changed files with 16 additions and 6 deletions

View File

@@ -178,6 +178,15 @@ describe('Scope', function(){
expect(log).toEqual('abc');
});
it('should repeat watch cycle from the root elemnt', function(){
var log = '';
var child = root.$new();
root.$watch(function(){ log += 'a'; });
child.$watch(function(){ log += 'b'; });
root.$digest();
expect(log).toEqual('abab');
});
it('should prevent infinite recursion', function(){
root.$watch('a', function(self, v){self.b++;});