fix(compiler): make view engine work with Aot

This commit is contained in:
Tobias Bosch
2017-02-17 08:56:49 -08:00
committed by Igor Minar
parent 2ddd1c3ed2
commit 58ba4f0409
15 changed files with 176 additions and 75 deletions

View File

@ -27,7 +27,7 @@ import {ComponentFactory, ComponentRef} from './linker/component_factory';
import {ComponentFactoryResolver} from './linker/component_factory_resolver';
import {NgModuleFactory, NgModuleInjector, NgModuleRef} from './linker/ng_module_factory';
import {AppView} from './linker/view';
import {ViewRef, ViewRef_} from './linker/view_ref';
import {InternalViewRef, ViewRef} from './linker/view_ref';
import {WtfScopeFn, wtfCreateScope, wtfLeave} from './profile/profile';
import {Testability, TestabilityRegistry} from './testability/testability';
import {Type} from './type';
@ -424,7 +424,7 @@ export class ApplicationRef_ extends ApplicationRef {
private _bootstrapListeners: ((compRef: ComponentRef<any>) => void)[] = [];
private _rootComponents: ComponentRef<any>[] = [];
private _rootComponentTypes: Type<any>[] = [];
private _views: AppView<any>[] = [];
private _views: InternalViewRef[] = [];
private _runningTick: boolean = false;
private _enforceNoNewChanges: boolean = false;
private _isStable: Observable<boolean>;
@ -485,15 +485,15 @@ export class ApplicationRef_ extends ApplicationRef {
}
attachView(viewRef: ViewRef): void {
const view = (viewRef as ViewRef_<any>).internalView;
const view = (viewRef as InternalViewRef);
this._views.push(view);
view.attachToAppRef(this);
}
detachView(viewRef: ViewRef): void {
const view = (viewRef as ViewRef_<any>).internalView;
const view = (viewRef as InternalViewRef);
ListWrapper.remove(this._views, view);
view.detach();
view.detachFromContainer();
}
bootstrap<C>(componentOrFactory: ComponentFactory<C>|Type<C>): ComponentRef<C> {
@ -547,9 +547,9 @@ export class ApplicationRef_ extends ApplicationRef {
const scope = ApplicationRef_._tickScope();
try {
this._runningTick = true;
this._views.forEach((view) => view.ref.detectChanges());
this._views.forEach((view) => view.detectChanges());
if (this._enforceNoNewChanges) {
this._views.forEach((view) => view.ref.checkNoChanges());
this._views.forEach((view) => view.checkNoChanges());
}
} finally {
this._runningTick = false;