diff options
| author | Misko Hevery | 2011-08-11 15:02:08 -0700 | 
|---|---|---|
| committer | Misko Hevery | 2011-08-12 15:47:44 -0700 | 
| commit | 1c9fc1e1dec67c8c05f02da1e0853439238c4d8e (patch) | |
| tree | b943174db170b198924b162eac523f6d50f52245 /src/Scope.js | |
| parent | 8bc7beacd80814102a6b08b83283ccf8614e44d4 (diff) | |
| download | angular.js-1c9fc1e1dec67c8c05f02da1e0853439238c4d8e.tar.bz2 | |
fix(scope): rerun $digest from root, rather then per scope.
Diffstat (limited to 'src/Scope.js')
| -rw-r--r-- | src/Scope.js | 13 | 
1 files changed, 7 insertions, 6 deletions
| diff --git a/src/Scope.js b/src/Scope.js index 572e9760..370c4bec 100644 --- a/src/Scope.js +++ b/src/Scope.js @@ -389,14 +389,15 @@ Scope.prototype = {          watch, value, last,          watchers = this.$$watchers,          length, count = 0, -        iterationCount, ttl = 100; +        dirtyCount, ttl = 100, +        recheck = !this.$parent || !this.$parent.$$phase;      if (this.$$phase) {        throw Error(this.$$phase + ' already in progress');      }      this.$$phase = '$digest';      do { -      iterationCount = 0; +      dirtyCount = 0;        if (watchers) {          // process our watches          length = watchers.length; @@ -406,7 +407,7 @@ Scope.prototype = {              // Most common watches are on primitives, in which case we can short              // circuit it with === operator, only when === fails do we use .equals              if ((value = watch.get(this)) !== (last = watch.last) && !equals(value, last)) { -              iterationCount++; +              dirtyCount++;                watch.fn(this, watch.last = copy(value), last);              }            } catch (e) { @@ -416,14 +417,14 @@ Scope.prototype = {        }        child = this.$$childHead;        while(child) { -        iterationCount += child.$digest(); +        dirtyCount += child.$digest();          child = child.$$nextSibling;        } -      count += iterationCount; +      count += dirtyCount;        if(!(ttl--)) {          throw Error('100 $digest() iterations reached. Aborting!');        } -    } while (iterationCount); +    } while (recheck && dirtyCount);      this.$$phase = null;      return count;    }, | 
