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

Commit 99a2d37

Browse files
vicbrkirov
authored andcommitted
fix(RootScope): set the scope on ScopeAware root context
fixes #1554
1 parent 3eac327 commit 99a2d37

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

lib/core/scope.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -773,6 +773,7 @@ class RootScope extends Scope {
773773
_zone.onError = (e, s, ls) => _exceptionHandler(e, s);
774774
_zone.onScheduleMicrotask = runAsync;
775775
cacheRegister.registerCache("ScopeWatchASTs", astCache);
776+
if (context is ScopeAware) context.scope = this;
776777
}
777778

778779
RootScope get rootScope => this;

test/core/scope_spec.dart

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,18 @@ void main() {
2424
..bind(ScopeStatsEmitter, toImplementation: MockScopeStatsEmitter);
2525
});
2626

27+
describe('Root context', () {
28+
beforeEachModule((Module module) {
29+
module.bind(Object, toImplementation: _RootContext);
30+
});
31+
32+
it('should set the scope when RootContext is ScopeAware',
33+
(RootScope rootScope, Object rootContext) {
34+
expect(rootContext).toBeAnInstanceOf(_RootContext);
35+
expect((rootContext as _RootContext).scope).toBe(rootScope);
36+
});
37+
});
38+
2739
describe('AST Bridge', () {
2840
it('should watch field', (Logger logger, Map context, RootScope rootScope) {
2941
context['field'] = 'Worked!';
@@ -1751,3 +1763,7 @@ class UnstableList {
17511763
class Foo {
17521764
increment(x) => x+1;
17531765
}
1766+
1767+
class _RootContext implements ScopeAware {
1768+
var scope;
1769+
}

0 commit comments

Comments
 (0)