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

Commit

Permalink
fix(RootScope): set the scope on ScopeAware root context
Browse files Browse the repository at this point in the history
fixes #1554
  • Loading branch information
vicb authored and rkirov committed Dec 16, 2014
1 parent 3eac327 commit 99a2d37
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/core/scope.dart
Original file line number Diff line number Diff line change
Expand Up @@ -773,6 +773,7 @@ class RootScope extends Scope {
_zone.onError = (e, s, ls) => _exceptionHandler(e, s);
_zone.onScheduleMicrotask = runAsync;
cacheRegister.registerCache("ScopeWatchASTs", astCache);
if (context is ScopeAware) context.scope = this;
}

RootScope get rootScope => this;
Expand Down
16 changes: 16 additions & 0 deletions test/core/scope_spec.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,18 @@ void main() {
..bind(ScopeStatsEmitter, toImplementation: MockScopeStatsEmitter);
});

describe('Root context', () {
beforeEachModule((Module module) {
module.bind(Object, toImplementation: _RootContext);
});

it('should set the scope when RootContext is ScopeAware',
(RootScope rootScope, Object rootContext) {
expect(rootContext).toBeAnInstanceOf(_RootContext);
expect((rootContext as _RootContext).scope).toBe(rootScope);
});
});

describe('AST Bridge', () {
it('should watch field', (Logger logger, Map context, RootScope rootScope) {
context['field'] = 'Worked!';
Expand Down Expand Up @@ -1751,3 +1763,7 @@ class UnstableList {
class Foo {
increment(x) => x+1;
}

class _RootContext implements ScopeAware {
var scope;
}

0 comments on commit 99a2d37

Please sign in to comment.