Skip to content
This repository has been archived by the owner on Feb 22, 2018. It is now read-only.

Commit

Permalink
fix(scope): add scope id for easier debugging.
Browse files Browse the repository at this point in the history
  • Loading branch information
mhevery committed Mar 11, 2014
1 parent 322f2b6 commit 5a36808
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
10 changes: 7 additions & 3 deletions lib/core/scope.dart
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,8 @@ class ScopeLocals implements Map {
* for change detection, change processing and memory management.
*/
class Scope {
final String id;
int _childScopeNextId = 0;

/**
* The default execution context for [watch]es [observe]ers, and [eval]uation.
Expand Down Expand Up @@ -182,7 +184,7 @@ class Scope {
bool get hasOwnStreams => _streams != null && _streams._scope == this;

Scope(Object this.context, this.rootScope, this._parentScope,
this._readWriteGroup, this._readOnlyGroup);
this._readWriteGroup, this._readOnlyGroup, this.id);

/**
* A [watch] sets up a watch in the [digest] phase of the [apply] cycle.
Expand Down Expand Up @@ -271,7 +273,8 @@ class Scope {
assert(isAttached);
var child = new Scope(childContext, rootScope, this,
_readWriteGroup.newGroup(childContext),
_readOnlyGroup.newGroup(childContext));
_readOnlyGroup.newGroup(childContext),
'$id:${_childScopeNextId++}');

var prev = _childTail;
child._prev = prev;
Expand Down Expand Up @@ -422,7 +425,8 @@ class RootScope extends Scope {
this._scopeStats)
: super(context, null, null,
new RootWatchGroup(new DirtyCheckingChangeDetector(cacheGetter), context),
new RootWatchGroup(new DirtyCheckingChangeDetector(cacheGetter), context))
new RootWatchGroup(new DirtyCheckingChangeDetector(cacheGetter), context),
'')
{
_zone.onTurnDone = apply;
_zone.onError = (e, s, ls) => _exceptionHandler(e, s);
Expand Down
2 changes: 2 additions & 0 deletions test/core/scope_spec.dart
Original file line number Diff line number Diff line change
Expand Up @@ -224,11 +224,13 @@ void main() {
describe('parent', () {
it('should not have parent', inject((RootScope rootScope) {
expect(rootScope.parentScope).toEqual(null);
expect(rootScope.id).toEqual('');
}));


it('should point to parent', inject((RootScope rootScope) {
var child = rootScope.createChild(new PrototypeMap(rootScope.context));
expect(child.id).toEqual(':0');
expect(rootScope.parentScope).toEqual(null);
expect(child.parentScope).toEqual(rootScope);
expect(child.createChild(new PrototypeMap(rootScope.context)).parentScope).toEqual(child);
Expand Down

0 comments on commit 5a36808

Please sign in to comment.