refactor(core): Remove circular dependency on ApplicationRef (#39621)

`ViewRef` and `ApplicationRef` had a circular reference. This change
introduces `ViewRefTracker` which is a subset of `ApplicationRef` for
this purpose.

PR Close #39621
This commit is contained in:
Misko Hevery 2020-11-10 12:24:46 -08:00 committed by atscott
parent 1ac68e3f2b
commit c461acd12e
7 changed files with 64 additions and 358 deletions

View File

@ -112,369 +112,50 @@
"packages/compiler/src/render3/view/styling_builder.ts", "packages/compiler/src/render3/view/styling_builder.ts",
"packages/compiler/src/render3/view/template.ts" "packages/compiler/src/render3/view/template.ts"
], ],
[
"packages/core/src/application_ref.ts",
"packages/core/src/application_tokens.ts",
"packages/core/src/linker/component_factory.ts",
"packages/core/src/change_detection/change_detection.ts",
"packages/core/src/change_detection/change_detector_ref.ts",
"packages/core/src/render3/view_ref.ts"
],
[
"packages/core/src/application_ref.ts",
"packages/core/src/error_handler.ts",
"packages/core/src/errors.ts",
"packages/core/src/view/types.ts",
"packages/core/src/linker/component_factory.ts",
"packages/core/src/change_detection/change_detection.ts",
"packages/core/src/change_detection/change_detector_ref.ts",
"packages/core/src/render3/view_ref.ts"
],
[
"packages/core/src/application_ref.ts",
"packages/core/src/linker/compiler.ts",
"packages/core/src/linker/component_factory.ts",
"packages/core/src/change_detection/change_detection.ts",
"packages/core/src/change_detection/change_detector_ref.ts",
"packages/core/src/render3/view_ref.ts"
],
[ [
"packages/core/src/application_ref.ts", "packages/core/src/application_ref.ts",
"packages/core/src/linker/compiler.ts", "packages/core/src/linker/compiler.ts",
"packages/core/src/metadata.ts", "packages/core/src/metadata.ts",
"packages/core/src/metadata/directives.ts", "packages/core/src/metadata/do_boostrap.ts"
"packages/core/src/render3/jit/directive.ts", ],
"packages/core/src/render3/jit/environment.ts", [
"packages/core/src/render3/index.ts",
"packages/core/src/render3/component.ts",
"packages/core/src/render3/instructions/shared.ts",
"packages/core/src/error_handler.ts",
"packages/core/src/errors.ts",
"packages/core/src/view/types.ts",
"packages/core/src/linker/component_factory.ts",
"packages/core/src/change_detection/change_detection.ts", "packages/core/src/change_detection/change_detection.ts",
"packages/core/src/change_detection/change_detector_ref.ts", "packages/core/src/change_detection/change_detector_ref.ts",
"packages/core/src/render3/view_ref.ts" "packages/core/src/render3/view_ref.ts",
"packages/core/src/linker/view_container_ref.ts",
"packages/core/src/linker/component_factory.ts"
], ],
[ [
"packages/core/src/application_ref.ts", "packages/core/src/change_detection/change_detection.ts",
"packages/core/src/linker/compiler.ts",
"packages/core/src/render3/component_ref.ts",
"packages/core/src/change_detection/change_detector_ref.ts", "packages/core/src/change_detection/change_detector_ref.ts",
"packages/core/src/render3/view_ref.ts" "packages/core/src/render3/view_ref.ts",
], "packages/core/src/linker/view_container_ref.ts",
[ "packages/core/src/linker/ng_module_factory.ts",
"packages/core/src/application_ref.ts",
"packages/core/src/linker/compiler.ts",
"packages/core/src/render3/component_ref.ts",
"packages/core/src/linker/component_factory_resolver.ts", "packages/core/src/linker/component_factory_resolver.ts",
"packages/core/src/linker/component_factory.ts", "packages/core/src/linker/component_factory.ts"
],
[
"packages/core/src/change_detection/change_detection.ts", "packages/core/src/change_detection/change_detection.ts",
"packages/core/src/change_detection/change_detector_ref.ts", "packages/core/src/change_detection/change_detector_ref.ts",
"packages/core/src/render3/view_ref.ts" "packages/core/src/render3/view_ref.ts",
],
[
"packages/core/src/application_ref.ts",
"packages/core/src/linker/compiler.ts",
"packages/core/src/render3/component_ref.ts",
"packages/core/src/linker/component_factory.ts",
"packages/core/src/change_detection/change_detection.ts",
"packages/core/src/change_detection/change_detector_ref.ts",
"packages/core/src/render3/view_ref.ts"
],
[
"packages/core/src/application_ref.ts",
"packages/core/src/linker/compiler.ts",
"packages/core/src/render3/component_ref.ts",
"packages/core/src/render3/component.ts",
"packages/core/src/render3/instructions/shared.ts",
"packages/core/src/error_handler.ts",
"packages/core/src/errors.ts",
"packages/core/src/view/types.ts",
"packages/core/src/linker/component_factory.ts",
"packages/core/src/change_detection/change_detection.ts",
"packages/core/src/change_detection/change_detector_ref.ts",
"packages/core/src/render3/view_ref.ts"
],
[
"packages/core/src/application_ref.ts",
"packages/core/src/linker/compiler.ts",
"packages/core/src/render3/component_ref.ts",
"packages/core/src/render3/instructions/shared.ts",
"packages/core/src/error_handler.ts",
"packages/core/src/errors.ts",
"packages/core/src/view/types.ts",
"packages/core/src/linker/component_factory.ts",
"packages/core/src/change_detection/change_detection.ts",
"packages/core/src/change_detection/change_detector_ref.ts",
"packages/core/src/render3/view_ref.ts"
],
[
"packages/core/src/application_ref.ts",
"packages/core/src/linker/compiler.ts",
"packages/core/src/render3/component_ref.ts",
"packages/core/src/render3/view_ref.ts"
],
[
"packages/core/src/application_ref.ts",
"packages/core/src/linker/compiler.ts",
"packages/core/src/render3/component_ref.ts",
"packages/core/src/view/provider.ts",
"packages/core/src/change_detection/change_detection.ts",
"packages/core/src/change_detection/change_detector_ref.ts",
"packages/core/src/render3/view_ref.ts"
],
[
"packages/core/src/application_ref.ts",
"packages/core/src/linker/compiler.ts",
"packages/core/src/render3/component_ref.ts",
"packages/core/src/view/provider.ts",
"packages/core/src/linker/template_ref.ts",
"packages/core/src/linker/view_ref.ts"
],
[
"packages/core/src/application_ref.ts",
"packages/core/src/linker/compiler.ts",
"packages/core/src/render3/component_ref.ts",
"packages/core/src/view/provider.ts",
"packages/core/src/linker/template_ref.ts",
"packages/core/src/linker/view_ref.ts",
"packages/core/src/change_detection/change_detector_ref.ts",
"packages/core/src/render3/view_ref.ts"
],
[
"packages/core/src/application_ref.ts",
"packages/core/src/linker/compiler.ts",
"packages/core/src/render3/component_ref.ts",
"packages/core/src/view/provider.ts",
"packages/core/src/linker/template_ref.ts",
"packages/core/src/render3/instructions/shared.ts",
"packages/core/src/error_handler.ts",
"packages/core/src/errors.ts",
"packages/core/src/view/types.ts",
"packages/core/src/linker/component_factory.ts",
"packages/core/src/change_detection/change_detection.ts",
"packages/core/src/change_detection/change_detector_ref.ts",
"packages/core/src/render3/view_ref.ts"
],
[
"packages/core/src/application_ref.ts",
"packages/core/src/linker/compiler.ts",
"packages/core/src/render3/component_ref.ts",
"packages/core/src/view/provider.ts",
"packages/core/src/linker/template_ref.ts",
"packages/core/src/render3/view_ref.ts"
],
[
"packages/core/src/application_ref.ts",
"packages/core/src/linker/compiler.ts",
"packages/core/src/render3/component_ref.ts",
"packages/core/src/view/provider.ts",
"packages/core/src/linker/view_container_ref.ts", "packages/core/src/linker/view_container_ref.ts",
"packages/core/src/linker/component_factory.ts", "packages/core/src/linker/template_ref.ts",
"packages/core/src/change_detection/change_detection.ts", "packages/core/src/render3/instructions/shared.ts",
"packages/core/src/change_detection/change_detector_ref.ts", "packages/core/src/error_handler.ts",
"packages/core/src/render3/view_ref.ts" "packages/core/src/errors.ts",
"packages/core/src/view/types.ts",
"packages/core/src/linker/component_factory.ts"
], ],
[ [
"packages/core/src/application_ref.ts", "packages/core/src/change_detection/change_detection.ts",
"packages/core/src/linker/compiler.ts", "packages/core/src/change_detection/change_detector_ref.ts",
"packages/core/src/render3/component_ref.ts", "packages/core/src/render3/view_ref.ts",
"packages/core/src/view/provider.ts",
"packages/core/src/linker/view_container_ref.ts", "packages/core/src/linker/view_container_ref.ts",
"packages/core/src/render3/instructions/shared.ts", "packages/core/src/render3/instructions/shared.ts",
"packages/core/src/error_handler.ts", "packages/core/src/error_handler.ts",
"packages/core/src/errors.ts", "packages/core/src/errors.ts",
"packages/core/src/view/types.ts", "packages/core/src/view/types.ts",
"packages/core/src/linker/component_factory.ts", "packages/core/src/linker/component_factory.ts"
"packages/core/src/change_detection/change_detection.ts",
"packages/core/src/change_detection/change_detector_ref.ts",
"packages/core/src/render3/view_ref.ts"
],
[
"packages/core/src/application_ref.ts",
"packages/core/src/linker/compiler.ts",
"packages/core/src/render3/component_ref.ts",
"packages/core/src/view/provider.ts",
"packages/core/src/linker/view_container_ref.ts",
"packages/core/src/render3/view_ref.ts"
],
[
"packages/core/src/application_ref.ts",
"packages/core/src/linker/compiler.ts",
"packages/core/src/render3/component_ref.ts",
"packages/core/src/view/provider.ts",
"packages/core/src/view/refs.ts"
],
[
"packages/core/src/application_ref.ts",
"packages/core/src/linker/compiler.ts",
"packages/core/src/render3/component_ref.ts",
"packages/core/src/view/provider.ts",
"packages/core/src/view/refs.ts",
"packages/core/src/change_detection/change_detection.ts",
"packages/core/src/change_detection/change_detector_ref.ts",
"packages/core/src/render3/view_ref.ts"
],
[
"packages/core/src/application_ref.ts",
"packages/core/src/linker/compiler.ts",
"packages/core/src/render3/component_ref.ts",
"packages/core/src/view/provider.ts",
"packages/core/src/view/refs.ts",
"packages/core/src/linker/component_factory.ts",
"packages/core/src/change_detection/change_detection.ts",
"packages/core/src/change_detection/change_detector_ref.ts",
"packages/core/src/render3/view_ref.ts"
],
[
"packages/core/src/application_ref.ts",
"packages/core/src/linker/compiler.ts",
"packages/core/src/render3/component_ref.ts",
"packages/core/src/view/provider.ts",
"packages/core/src/view/refs.ts",
"packages/core/src/view/ng_module.ts",
"packages/core/src/view/types.ts",
"packages/core/src/linker/component_factory.ts",
"packages/core/src/change_detection/change_detection.ts",
"packages/core/src/change_detection/change_detector_ref.ts",
"packages/core/src/render3/view_ref.ts"
],
[
"packages/core/src/application_ref.ts",
"packages/core/src/linker/compiler.ts",
"packages/core/src/render3/component_ref.ts",
"packages/core/src/view/provider.ts",
"packages/core/src/view/refs.ts",
"packages/core/src/view/ng_module.ts",
"packages/core/src/view/util.ts",
"packages/core/src/change_detection/change_detection.ts",
"packages/core/src/change_detection/change_detector_ref.ts",
"packages/core/src/render3/view_ref.ts"
],
[
"packages/core/src/application_ref.ts",
"packages/core/src/linker/compiler.ts",
"packages/core/src/render3/component_ref.ts",
"packages/core/src/view/provider.ts",
"packages/core/src/view/refs.ts",
"packages/core/src/view/ng_module.ts",
"packages/core/src/view/util.ts",
"packages/core/src/view/errors.ts",
"packages/core/src/errors.ts",
"packages/core/src/view/types.ts",
"packages/core/src/linker/component_factory.ts",
"packages/core/src/change_detection/change_detection.ts",
"packages/core/src/change_detection/change_detector_ref.ts",
"packages/core/src/render3/view_ref.ts"
],
[
"packages/core/src/application_ref.ts",
"packages/core/src/linker/compiler.ts",
"packages/core/src/render3/component_ref.ts",
"packages/core/src/view/provider.ts",
"packages/core/src/view/refs.ts",
"packages/core/src/view/ng_module.ts",
"packages/core/src/view/util.ts",
"packages/core/src/view/errors.ts",
"packages/core/src/view/types.ts",
"packages/core/src/linker/component_factory.ts",
"packages/core/src/change_detection/change_detection.ts",
"packages/core/src/change_detection/change_detector_ref.ts",
"packages/core/src/render3/view_ref.ts"
],
[
"packages/core/src/application_ref.ts",
"packages/core/src/linker/compiler.ts",
"packages/core/src/render3/component_ref.ts",
"packages/core/src/view/provider.ts",
"packages/core/src/view/refs.ts",
"packages/core/src/view/ng_module.ts",
"packages/core/src/view/util.ts",
"packages/core/src/view/types.ts",
"packages/core/src/linker/component_factory.ts",
"packages/core/src/change_detection/change_detection.ts",
"packages/core/src/change_detection/change_detector_ref.ts",
"packages/core/src/render3/view_ref.ts"
],
[
"packages/core/src/application_ref.ts",
"packages/core/src/linker/compiler.ts",
"packages/core/src/render3/component_ref.ts",
"packages/core/src/view/provider.ts",
"packages/core/src/view/refs.ts",
"packages/core/src/view/types.ts",
"packages/core/src/linker/component_factory.ts",
"packages/core/src/change_detection/change_detection.ts",
"packages/core/src/change_detection/change_detector_ref.ts",
"packages/core/src/render3/view_ref.ts"
],
[
"packages/core/src/application_ref.ts",
"packages/core/src/linker/compiler.ts",
"packages/core/src/render3/component_ref.ts",
"packages/core/src/view/provider.ts",
"packages/core/src/view/refs.ts",
"packages/core/src/view/view_attach.ts",
"packages/core/src/view/types.ts",
"packages/core/src/linker/component_factory.ts",
"packages/core/src/change_detection/change_detection.ts",
"packages/core/src/change_detection/change_detector_ref.ts",
"packages/core/src/render3/view_ref.ts"
],
[
"packages/core/src/application_ref.ts",
"packages/core/src/linker/compiler.ts",
"packages/core/src/render3/component_ref.ts",
"packages/core/src/view/provider.ts",
"packages/core/src/view/types.ts",
"packages/core/src/linker/component_factory.ts",
"packages/core/src/change_detection/change_detection.ts",
"packages/core/src/change_detection/change_detector_ref.ts",
"packages/core/src/render3/view_ref.ts"
],
[
"packages/core/src/application_ref.ts",
"packages/core/src/linker/component_factory.ts",
"packages/core/src/change_detection/change_detection.ts",
"packages/core/src/change_detection/change_detector_ref.ts",
"packages/core/src/render3/view_ref.ts"
],
[
"packages/core/src/application_ref.ts",
"packages/core/src/render3/util/global_utils.ts",
"packages/core/src/render3/util/change_detection_utils.ts",
"packages/core/src/render3/instructions/change_detection.ts",
"packages/core/src/render3/instructions/shared.ts",
"packages/core/src/error_handler.ts",
"packages/core/src/errors.ts",
"packages/core/src/view/types.ts",
"packages/core/src/linker/component_factory.ts",
"packages/core/src/change_detection/change_detection.ts",
"packages/core/src/change_detection/change_detector_ref.ts",
"packages/core/src/render3/view_ref.ts"
],
[
"packages/core/src/application_ref.ts",
"packages/core/src/render3/util/global_utils.ts",
"packages/core/src/render3/util/change_detection_utils.ts",
"packages/core/src/render3/util/discovery_utils.ts",
"packages/core/src/render3/instructions/lview_debug.ts",
"packages/core/src/core.ts",
"packages/core/src/metadata.ts",
"packages/core/src/metadata/directives.ts",
"packages/core/src/render3/jit/directive.ts",
"packages/core/src/render3/jit/environment.ts",
"packages/core/src/render3/index.ts",
"packages/core/src/render3/component.ts",
"packages/core/src/render3/instructions/shared.ts",
"packages/core/src/error_handler.ts",
"packages/core/src/errors.ts",
"packages/core/src/view/types.ts",
"packages/core/src/linker/component_factory.ts",
"packages/core/src/change_detection/change_detection.ts",
"packages/core/src/change_detection/change_detector_ref.ts",
"packages/core/src/render3/view_ref.ts"
], ],
[ [
"packages/core/src/change_detection/change_detection.ts", "packages/core/src/change_detection/change_detection.ts",
@ -490,6 +171,13 @@
"packages/core/src/change_detection/change_detector_ref.ts", "packages/core/src/change_detection/change_detector_ref.ts",
"packages/core/src/render3/view_ref.ts" "packages/core/src/render3/view_ref.ts"
], ],
[
"packages/core/src/change_detection/change_detector_ref.ts",
"packages/core/src/render3/view_ref.ts",
"packages/core/src/linker/view_container_ref.ts",
"packages/core/src/linker/template_ref.ts",
"packages/core/src/linker/view_ref.ts"
],
[ [
"packages/core/src/change_detection/differs/default_iterable_differ.ts", "packages/core/src/change_detection/differs/default_iterable_differ.ts",
"packages/core/src/change_detection/differs/iterable_differs.ts" "packages/core/src/change_detection/differs/iterable_differs.ts"
@ -607,6 +295,15 @@
"packages/core/src/linker/component_factory_resolver.ts", "packages/core/src/linker/component_factory_resolver.ts",
"packages/core/src/linker/ng_module_factory.ts" "packages/core/src/linker/ng_module_factory.ts"
], ],
[
"packages/core/src/linker/template_ref.ts",
"packages/core/src/render3/view_ref.ts",
"packages/core/src/linker/view_container_ref.ts"
],
[
"packages/core/src/linker/view_container_ref.ts",
"packages/core/src/render3/view_ref.ts"
],
[ [
"packages/core/src/metadata/directives.ts", "packages/core/src/metadata/directives.ts",
"packages/core/src/render3/jit/directive.ts" "packages/core/src/render3/jit/directive.ts"

View File

@ -364,11 +364,11 @@ const R3ViewContainerRef = class ViewContainerRef extends VE_ViewContainerRef {
}; };
function getViewRefs(lContainer: LContainer): ViewRef[]|null { function getViewRefs(lContainer: LContainer): ViewRef[]|null {
return lContainer[VIEW_REFS]; return lContainer[VIEW_REFS] as ViewRef[];
} }
function getOrCreateViewRefs(lContainer: LContainer): ViewRef[] { function getOrCreateViewRefs(lContainer: LContainer): ViewRef[] {
return lContainer[VIEW_REFS] || (lContainer[VIEW_REFS] = []); return (lContainer[VIEW_REFS] || (lContainer[VIEW_REFS] = [])) as ViewRef[];
} }
/** /**

View File

@ -6,7 +6,6 @@
* found in the LICENSE file at https://angular.io/license * found in the LICENSE file at https://angular.io/license
*/ */
import {ApplicationRef} from '../application_ref';
import {ChangeDetectorRef} from '../change_detection/change_detector_ref'; import {ChangeDetectorRef} from '../change_detection/change_detector_ref';
/** /**
@ -104,5 +103,15 @@ export abstract class EmbeddedViewRef<C> extends ViewRef {
export interface InternalViewRef extends ViewRef { export interface InternalViewRef extends ViewRef {
detachFromAppRef(): void; detachFromAppRef(): void;
attachToAppRef(appRef: ApplicationRef): void; attachToAppRef(appRef: ViewRefTracker): void;
}
/**
* Interface for tracking root `ViewRef`s in `ApplicationRef`.
*
* NOTE: Importing `ApplicationRef` here directly creates circular dependency, which is why we have
* a subset of the `ApplicationRef` interface `ViewRefTracker` here.
*/
export interface ViewRefTracker {
detachView(viewRef: ViewRef): void;
} }

View File

@ -6,7 +6,9 @@
* found in the LICENSE file at https://angular.io/license * found in the LICENSE file at https://angular.io/license
*/ */
import {Injector, SchemaMetadata, Type} from '../../core'; import {Injector} from '../../di/injector';
import {Type} from '../../interface/type';
import {SchemaMetadata} from '../../metadata/schema';
import {Sanitizer} from '../../sanitization/sanitizer'; import {Sanitizer} from '../../sanitization/sanitizer';
import {KeyValueArray} from '../../util/array_utils'; import {KeyValueArray} from '../../util/array_utils';
import {assertDefined} from '../../util/assert'; import {assertDefined} from '../../util/assert';

View File

@ -129,7 +129,7 @@ export interface LContainer extends Array<any> {
* NOTE: This is stored as `any[]` because render3 should really not be aware of `ViewRef` and * NOTE: This is stored as `any[]` because render3 should really not be aware of `ViewRef` and
* doing so creates circular dependency. * doing so creates circular dependency.
*/ */
[VIEW_REFS]: any[]|null; [VIEW_REFS]: unknown[]|null;
} }
// Note: This hack is necessary so we don't erroneously get a circular dependency // Note: This hack is necessary so we don't erroneously get a circular dependency

View File

@ -6,10 +6,9 @@
* found in the LICENSE file at https://angular.io/license * found in the LICENSE file at https://angular.io/license
*/ */
import {ApplicationRef} from '../application_ref';
import {ChangeDetectorRef as viewEngine_ChangeDetectorRef} from '../change_detection/change_detector_ref'; import {ChangeDetectorRef as viewEngine_ChangeDetectorRef} from '../change_detection/change_detector_ref';
import {ViewContainerRef as viewEngine_ViewContainerRef} from '../linker/view_container_ref'; import {ViewContainerRef as viewEngine_ViewContainerRef} from '../linker/view_container_ref';
import {EmbeddedViewRef as viewEngine_EmbeddedViewRef, InternalViewRef as viewEngine_InternalViewRef} from '../linker/view_ref'; import {EmbeddedViewRef as viewEngine_EmbeddedViewRef, InternalViewRef as viewEngine_InternalViewRef, ViewRefTracker} from '../linker/view_ref';
import {collectNativeNodes} from './collect_native_nodes'; import {collectNativeNodes} from './collect_native_nodes';
import {checkNoChangesInRootView, checkNoChangesInternal, detectChangesInRootView, detectChangesInternal, markViewDirty, storeCleanupWithContext} from './instructions/shared'; import {checkNoChangesInRootView, checkNoChangesInternal, detectChangesInRootView, detectChangesInternal, markViewDirty, storeCleanupWithContext} from './instructions/shared';
import {CONTEXT, FLAGS, LView, LViewFlags, TVIEW} from './interfaces/view'; import {CONTEXT, FLAGS, LView, LViewFlags, TVIEW} from './interfaces/view';
@ -24,7 +23,7 @@ export interface viewEngine_ChangeDetectorRef_interface extends viewEngine_Chang
export class ViewRef<T> implements viewEngine_EmbeddedViewRef<T>, viewEngine_InternalViewRef, export class ViewRef<T> implements viewEngine_EmbeddedViewRef<T>, viewEngine_InternalViewRef,
viewEngine_ChangeDetectorRef_interface { viewEngine_ChangeDetectorRef_interface {
private _appRef: ApplicationRef|null = null; private _appRef: ViewRefTracker|null = null;
private _viewContainerRef: viewEngine_ViewContainerRef|null = null; private _viewContainerRef: viewEngine_ViewContainerRef|null = null;
get rootNodes(): any[] { get rootNodes(): any[] {
@ -284,7 +283,7 @@ export class ViewRef<T> implements viewEngine_EmbeddedViewRef<T>, viewEngine_Int
renderDetachView(this._lView[TVIEW], this._lView); renderDetachView(this._lView[TVIEW], this._lView);
} }
attachToAppRef(appRef: ApplicationRef) { attachToAppRef(appRef: ViewRefTracker) {
if (this._viewContainerRef) { if (this._viewContainerRef) {
throw new Error('This view is already attached to a ViewContainer!'); throw new Error('This view is already attached to a ViewContainer!');
} }

View File

@ -6,7 +6,6 @@
* found in the LICENSE file at https://angular.io/license * found in the LICENSE file at https://angular.io/license
*/ */
import {ApplicationRef} from '../application_ref';
import {ChangeDetectorRef} from '../change_detection/change_detection'; import {ChangeDetectorRef} from '../change_detection/change_detection';
import {Injector} from '../di/injector'; import {Injector} from '../di/injector';
import {InjectFlags} from '../di/interface/injector'; import {InjectFlags} from '../di/interface/injector';
@ -17,13 +16,13 @@ import {ElementRef} from '../linker/element_ref';
import {InternalNgModuleRef, NgModuleRef} from '../linker/ng_module_factory'; import {InternalNgModuleRef, NgModuleRef} from '../linker/ng_module_factory';
import {TemplateRef} from '../linker/template_ref'; import {TemplateRef} from '../linker/template_ref';
import {ViewContainerRef} from '../linker/view_container_ref'; import {ViewContainerRef} from '../linker/view_container_ref';
import {EmbeddedViewRef, InternalViewRef, ViewRef} from '../linker/view_ref'; import {EmbeddedViewRef, InternalViewRef, ViewRef, ViewRefTracker} from '../linker/view_ref';
import {stringify} from '../util/stringify'; import {stringify} from '../util/stringify';
import {VERSION} from '../version'; import {VERSION} from '../version';
import {callNgModuleLifecycle, initNgModule, resolveNgModuleDep} from './ng_module'; import {callNgModuleLifecycle, initNgModule, resolveNgModuleDep} from './ng_module';
import {asElementData, asProviderData, asTextData, DepFlags, ElementData, NgModuleData, NgModuleDefinition, NodeDef, NodeFlags, Services, TemplateData, ViewContainerData, ViewData, ViewDefinitionFactory, ViewState} from './types'; import {asElementData, asProviderData, asTextData, DepFlags, ElementData, NgModuleData, NgModuleDefinition, NodeDef, NodeFlags, Services, TemplateData, ViewContainerData, ViewData, ViewDefinitionFactory, ViewState} from './types';
import {markParentViewsForCheck, resolveDefinition, rootRenderNodes, splitNamespace, tokenKey, viewParentEl} from './util'; import {markParentViewsForCheck, resolveDefinition, rootRenderNodes, tokenKey, viewParentEl} from './util';
import {attachEmbeddedView, detachEmbeddedView, moveEmbeddedView, renderDetachView} from './view_attach'; import {attachEmbeddedView, detachEmbeddedView, moveEmbeddedView, renderDetachView} from './view_attach';
const EMPTY_CONTEXT = {}; const EMPTY_CONTEXT = {};
@ -249,7 +248,7 @@ export class ViewRef_ implements EmbeddedViewRef<any>, InternalViewRef {
/** @internal */ /** @internal */
_view: ViewData; _view: ViewData;
private _viewContainerRef: ViewContainerRef|null; private _viewContainerRef: ViewContainerRef|null;
private _appRef: ApplicationRef|null; private _appRef: ViewRefTracker|null;
constructor(_view: ViewData) { constructor(_view: ViewData) {
this._view = _view; this._view = _view;
@ -317,7 +316,7 @@ export class ViewRef_ implements EmbeddedViewRef<any>, InternalViewRef {
Services.dirtyParentQueries(this._view); Services.dirtyParentQueries(this._view);
} }
attachToAppRef(appRef: ApplicationRef) { attachToAppRef(appRef: ViewRefTracker) {
if (this._viewContainerRef) { if (this._viewContainerRef) {
throw new Error('This view is already attached to a ViewContainer!'); throw new Error('This view is already attached to a ViewContainer!');
} }