Skip to content

Commit c157922

Browse files
committed
fix(view): changed view manager to hydrate change detector after creating directives
1 parent f863ea0 commit c157922

File tree

3 files changed

+27
-4
lines changed

3 files changed

+27
-4
lines changed

modules/angular2/src/core/compiler/view_manager_utils.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,6 @@ export class AppViewManagerUtils {
185185
}
186186
view.context = context;
187187
view.locals.parent = parentLocals;
188-
view.changeDetector.hydrate(view.context, view.locals, view);
189188

190189
var binders = view.proto.elementBinders;
191190
for (var i = 0; i < binders.length; ++i) {
@@ -212,7 +211,7 @@ export class AppViewManagerUtils {
212211
}
213212
}
214213
}
215-
214+
view.changeDetector.hydrate(view.context, view.locals, view);
216215
}
217216

218217
_setUpEventEmitters(view:viewModule.AppView, elementInjector:eli.ElementInjector, boundElementIndex:number) {

modules/angular2/src/test_lib/utils.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export class Log {
1414
}
1515

1616
fn(value) {
17-
return () => {
17+
return (a1 = null, a2 = null, a3 = null, a4 = null, a5 = null) => {
1818
ListWrapper.push(this._result, value);
1919
}
2020
}

modules/angular2/test/core/compiler/view_manager_utils_spec.js

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ import {
1212
beforeEachBindings,
1313
it,
1414
xit,
15-
SpyObject, proxy
15+
SpyObject, proxy,
16+
Log
1617
} from 'angular2/test_lib';
1718

1819
import {Injector, bind} from 'angular2/di';
@@ -114,6 +115,29 @@ export function main() {
114115

115116
});
116117

118+
describe("hydrateComponentView", () => {
119+
120+
it("should hydrate the change detector after hydrating element injectors", () => {
121+
var log = new Log();
122+
123+
var componentView = createView(createProtoView([createEmptyElBinder()]));
124+
var hostView = createView(createProtoView([createComponentElBinder(createProtoView())]));
125+
hostView.componentChildViews = [componentView];
126+
127+
// (() => () nonsense is required until our transpiler supports type casting
128+
var spyEi = (() => componentView.elementInjectors[0])();
129+
spyEi.spy('instantiateDirectives').andCallFake(log.fn('instantiateDirectives'));
130+
131+
var spyCd = (() => componentView.changeDetector)();
132+
spyCd.spy('hydrate').andCallFake(log.fn('hydrateCD'));
133+
134+
utils.hydrateComponentView(hostView, 0)
135+
136+
expect(log.result()).toEqual('instantiateDirectives; hydrateCD');
137+
});
138+
139+
});
140+
117141
describe('shared hydrate functionality', () => {
118142

119143
it("should set up event listeners", () => {

0 commit comments

Comments
 (0)