fix(compiler): make view engine work with Aot
This commit is contained in:
@ -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;
|
||||
|
@ -7,10 +7,13 @@
|
||||
*/
|
||||
|
||||
import {AnimationQueue} from '../animation/animation_queue';
|
||||
import {ApplicationRef} from '../application_ref';
|
||||
import {ChangeDetectorRef} from '../change_detection/change_detector_ref';
|
||||
import {ChangeDetectorStatus} from '../change_detection/constants';
|
||||
|
||||
import {AppView} from './view';
|
||||
|
||||
|
||||
/**
|
||||
* @stable
|
||||
*/
|
||||
@ -85,7 +88,12 @@ export abstract class EmbeddedViewRef<C> extends ViewRef {
|
||||
abstract get rootNodes(): any[];
|
||||
}
|
||||
|
||||
export class ViewRef_<C> implements EmbeddedViewRef<C>, ChangeDetectorRef {
|
||||
export interface InternalViewRef extends ViewRef {
|
||||
detachFromContainer(): void;
|
||||
attachToAppRef(appRef: ApplicationRef): void;
|
||||
}
|
||||
|
||||
export class ViewRef_<C> implements EmbeddedViewRef<C>, ChangeDetectorRef, InternalViewRef {
|
||||
/** @internal */
|
||||
_originalMode: ChangeDetectorStatus;
|
||||
|
||||
@ -122,4 +130,8 @@ export class ViewRef_<C> implements EmbeddedViewRef<C>, ChangeDetectorRef {
|
||||
}
|
||||
|
||||
destroy() { this._view.detachAndDestroy(); }
|
||||
|
||||
detachFromContainer() { this._view.detach(); }
|
||||
|
||||
attachToAppRef(appRef: ApplicationRef) { this._view.attachToAppRef(appRef); }
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ import {ComponentFactory, ComponentRef} from '../linker/component_factory';
|
||||
import {ElementRef} from '../linker/element_ref';
|
||||
import {TemplateRef} from '../linker/template_ref';
|
||||
import {ViewContainerRef} from '../linker/view_container_ref';
|
||||
import {EmbeddedViewRef, ViewRef} from '../linker/view_ref';
|
||||
import {EmbeddedViewRef, InternalViewRef, ViewRef} from '../linker/view_ref';
|
||||
import {Renderer as RendererV1, RendererV2} from '../render/api';
|
||||
import {Type} from '../type';
|
||||
import {VERSION} from '../version';
|
||||
@ -162,7 +162,7 @@ export function createChangeDetectorRef(view: ViewData): ChangeDetectorRef {
|
||||
return new ViewRef_(view);
|
||||
}
|
||||
|
||||
export class ViewRef_ implements EmbeddedViewRef<any> {
|
||||
export class ViewRef_ implements EmbeddedViewRef<any>, InternalViewRef {
|
||||
/** @internal */
|
||||
_view: ViewData;
|
||||
private _viewContainerRef: ViewContainerRef;
|
||||
|
@ -1333,7 +1333,6 @@ function declareTests({useJit, viewEngine}: {useJit: boolean, viewEngine: boolea
|
||||
expect(getDOM().nodeName(c.renderNode).toUpperCase()).toEqual('INPUT');
|
||||
expect(getDOM().nodeName(c.componentRenderElement).toUpperCase()).toEqual('DIV');
|
||||
expect((<Injector>c.injector).get).toBeTruthy();
|
||||
expect(c.source).toContain(':0:7');
|
||||
expect(c.context).toBe(fixture.componentInstance);
|
||||
expect(c.references['local']).toBeDefined();
|
||||
}
|
||||
@ -1351,7 +1350,6 @@ function declareTests({useJit, viewEngine}: {useJit: boolean, viewEngine: boolea
|
||||
} catch (e) {
|
||||
const c = getDebugContext(e);
|
||||
expect(c.renderNode).toBeTruthy();
|
||||
expect(c.source).toContain(':0:5');
|
||||
}
|
||||
});
|
||||
|
||||
|
Reference in New Issue
Block a user