refactor(core): Cleanup circular dependency between ViewEngine and Ivy `TemplateRef`. (#39621)
`TemplateRef` is declared in ViewEngine but it sub-classed in Ivy. This creates a circular dependency between ViewEngine `TemplateRef` which needs to declare `__NG_ELEMENT_ID__` and ivy factory which needs to create it. The workaround used to be to pass the `TemplateRef` through stack but that created a very convoluted code. This refactoring simply bundles the two files together and removes the stack workaround making the code simpler to follow. PR Close #39621
This commit is contained in:
parent
aa4924513b
commit
453f196c4d
|
@ -273,57 +273,7 @@
|
|||
"packages/core/src/change_detection/change_detection.ts",
|
||||
"packages/core/src/change_detection/change_detector_ref.ts",
|
||||
"packages/core/src/render3/view_engine_compatibility.ts",
|
||||
"packages/core/src/linker/view_container_ref.ts",
|
||||
"packages/core/src/di/injector.ts",
|
||||
"packages/core/src/di/r3_injector.ts",
|
||||
"packages/core/src/render3/definition.ts",
|
||||
"packages/core/src/metadata/ng_module.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_engine_compatibility.ts",
|
||||
"packages/core/src/render3/di.ts",
|
||||
"packages/core/src/di/injector_compatibility.ts",
|
||||
"packages/core/src/di/injector.ts",
|
||||
"packages/core/src/di/r3_injector.ts",
|
||||
"packages/core/src/render3/definition.ts",
|
||||
"packages/core/src/metadata/ng_module.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_engine_compatibility.ts",
|
||||
"packages/core/src/render3/di.ts",
|
||||
"packages/core/src/di/injector.ts",
|
||||
"packages/core/src/di/r3_injector.ts",
|
||||
"packages/core/src/render3/definition.ts",
|
||||
"packages/core/src/metadata/ng_module.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_engine_compatibility.ts",
|
||||
"packages/core/src/render3/di.ts",
|
||||
"packages/core/src/render3/definition.ts",
|
||||
"packages/core/src/metadata/ng_module.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_engine_compatibility.ts",
|
||||
"packages/core/src/linker/template_ref.ts",
|
||||
"packages/core/src/render3/instructions/shared.ts",
|
||||
"packages/core/src/di.ts",
|
||||
"packages/core/src/di/index.ts",
|
||||
|
@ -343,6 +293,7 @@
|
|||
"packages/core/src/change_detection/change_detection.ts",
|
||||
"packages/core/src/change_detection/change_detector_ref.ts",
|
||||
"packages/core/src/render3/view_engine_compatibility.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",
|
||||
|
@ -365,6 +316,25 @@
|
|||
"packages/core/src/change_detection/change_detection.ts",
|
||||
"packages/core/src/change_detection/change_detector_ref.ts",
|
||||
"packages/core/src/render3/view_engine_compatibility.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/view_container_ref.ts",
|
||||
"packages/core/src/di/injector.ts",
|
||||
"packages/core/src/di/r3_injector.ts",
|
||||
"packages/core/src/render3/definition.ts",
|
||||
"packages/core/src/metadata/ng_module.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_engine_compatibility.ts",
|
||||
"packages/core/src/linker/template_ref.ts",
|
||||
"packages/core/src/render3/instructions/shared.ts",
|
||||
"packages/core/src/render3/definition.ts",
|
||||
"packages/core/src/metadata/ng_module.ts"
|
||||
|
@ -376,6 +346,51 @@
|
|||
"packages/core/src/change_detection/change_detection.ts",
|
||||
"packages/core/src/change_detection/change_detector_ref.ts",
|
||||
"packages/core/src/render3/view_engine_compatibility.ts",
|
||||
"packages/core/src/linker/template_ref.ts",
|
||||
"packages/core/src/render3/instructions/shared.ts",
|
||||
"packages/core/src/render3/di.ts",
|
||||
"packages/core/src/di/injector_compatibility.ts",
|
||||
"packages/core/src/di/injector.ts",
|
||||
"packages/core/src/di/r3_injector.ts",
|
||||
"packages/core/src/render3/definition.ts",
|
||||
"packages/core/src/metadata/ng_module.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_engine_compatibility.ts",
|
||||
"packages/core/src/linker/template_ref.ts",
|
||||
"packages/core/src/render3/instructions/shared.ts",
|
||||
"packages/core/src/render3/di.ts",
|
||||
"packages/core/src/di/injector.ts",
|
||||
"packages/core/src/di/r3_injector.ts",
|
||||
"packages/core/src/render3/definition.ts",
|
||||
"packages/core/src/metadata/ng_module.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_engine_compatibility.ts",
|
||||
"packages/core/src/linker/template_ref.ts",
|
||||
"packages/core/src/render3/instructions/shared.ts",
|
||||
"packages/core/src/render3/di.ts",
|
||||
"packages/core/src/render3/definition.ts",
|
||||
"packages/core/src/metadata/ng_module.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_engine_compatibility.ts",
|
||||
"packages/core/src/linker/template_ref.ts",
|
||||
"packages/core/src/render3/instructions/shared.ts",
|
||||
"packages/core/src/render3/instructions/lview_debug.ts",
|
||||
"packages/core/src/core.ts",
|
||||
|
@ -398,6 +413,7 @@
|
|||
"packages/core/src/change_detection/change_detection.ts",
|
||||
"packages/core/src/change_detection/change_detector_ref.ts",
|
||||
"packages/core/src/render3/view_engine_compatibility.ts",
|
||||
"packages/core/src/linker/template_ref.ts",
|
||||
"packages/core/src/render3/view_ref.ts"
|
||||
],
|
||||
[
|
||||
|
@ -849,17 +865,23 @@
|
|||
"packages/core/src/change_detection/change_detection.ts",
|
||||
"packages/core/src/change_detection/change_detector_ref.ts",
|
||||
"packages/core/src/render3/view_engine_compatibility.ts",
|
||||
"packages/core/src/linker/view_container_ref.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_engine_compatibility.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/view_container_ref.ts",
|
||||
"packages/core/src/linker/component_factory.ts"
|
||||
],
|
||||
[
|
||||
|
@ -878,6 +900,7 @@
|
|||
[
|
||||
"packages/core/src/change_detection/change_detector_ref.ts",
|
||||
"packages/core/src/render3/view_engine_compatibility.ts",
|
||||
"packages/core/src/linker/template_ref.ts",
|
||||
"packages/core/src/render3/view_ref.ts"
|
||||
],
|
||||
[
|
||||
|
@ -928,6 +951,30 @@
|
|||
"packages/core/src/errors.ts",
|
||||
"packages/core/src/view/types.ts"
|
||||
],
|
||||
[
|
||||
"packages/core/src/error_handler.ts",
|
||||
"packages/core/src/errors.ts",
|
||||
"packages/core/src/view/types.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/view_container_ref.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/view_container_ref.ts",
|
||||
"packages/core/src/render3/view_engine_compatibility.ts",
|
||||
"packages/core/src/linker/template_ref.ts",
|
||||
"packages/core/src/render3/instructions/shared.ts"
|
||||
],
|
||||
[
|
||||
"packages/core/src/linker/component_factory_resolver.ts",
|
||||
"packages/core/src/linker/ng_module_factory.ts"
|
||||
|
@ -943,14 +990,6 @@
|
|||
"packages/core/src/linker/ng_module_factory_registration.ts",
|
||||
"packages/core/src/render3/ng_module_ref.ts"
|
||||
],
|
||||
[
|
||||
"packages/core/src/linker/template_ref.ts",
|
||||
"packages/core/src/render3/view_engine_compatibility.ts"
|
||||
],
|
||||
[
|
||||
"packages/core/src/linker/view_container_ref.ts",
|
||||
"packages/core/src/render3/view_engine_compatibility.ts"
|
||||
],
|
||||
[
|
||||
"packages/core/src/metadata/directives.ts",
|
||||
"packages/core/src/render3/jit/directive.ts"
|
||||
|
|
|
@ -6,13 +6,23 @@
|
|||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {injectTemplateRef as render3InjectTemplateRef} from '../render3/view_engine_compatibility';
|
||||
import {assertLContainer} from '../render3/assert';
|
||||
import {createLView, renderView} from '../render3/instructions/shared';
|
||||
import {TContainerNode, TNode, TNodeType} from '../render3/interfaces/node';
|
||||
import {DECLARATION_LCONTAINER, LView, LViewFlags, QUERIES, TView} from '../render3/interfaces/view';
|
||||
import {getCurrentTNode, getLView} from '../render3/state';
|
||||
import {ViewRef as R3_ViewRef} from '../render3/view_ref';
|
||||
import {assertDefined} from '../util/assert';
|
||||
import {noop} from '../util/noop';
|
||||
|
||||
import {ElementRef} from './element_ref';
|
||||
import {createElementRef, ElementRef} from './element_ref';
|
||||
import {EmbeddedViewRef} from './view_ref';
|
||||
|
||||
|
||||
|
||||
export const SWITCH_TEMPLATE_REF_FACTORY__POST_R3__ = injectTemplateRef;
|
||||
const SWITCH_TEMPLATE_REF_FACTORY__PRE_R3__ = noop;
|
||||
const SWITCH_TEMPLATE_REF_FACTORY: typeof injectTemplateRef = SWITCH_TEMPLATE_REF_FACTORY__PRE_R3__;
|
||||
|
||||
/**
|
||||
* Represents an embedded template that can be used to instantiate embedded views.
|
||||
* To instantiate embedded views based on a template, use the `ViewContainerRef`
|
||||
|
@ -59,11 +69,60 @@ export abstract class TemplateRef<C> {
|
|||
* @internal
|
||||
* @nocollapse
|
||||
*/
|
||||
static __NG_ELEMENT_ID__:
|
||||
() => TemplateRef<any>| null = () => SWITCH_TEMPLATE_REF_FACTORY(TemplateRef)
|
||||
static __NG_ELEMENT_ID__: () => TemplateRef<any>| null = SWITCH_TEMPLATE_REF_FACTORY;
|
||||
}
|
||||
|
||||
export const SWITCH_TEMPLATE_REF_FACTORY__POST_R3__ = render3InjectTemplateRef;
|
||||
const SWITCH_TEMPLATE_REF_FACTORY__PRE_R3__ = noop;
|
||||
const SWITCH_TEMPLATE_REF_FACTORY: typeof render3InjectTemplateRef =
|
||||
SWITCH_TEMPLATE_REF_FACTORY__PRE_R3__;
|
||||
const ViewEngineTemplateRef = TemplateRef;
|
||||
|
||||
const R3TemplateRef = class TemplateRef<T> extends ViewEngineTemplateRef<T> {
|
||||
constructor(
|
||||
private _declarationLView: LView, private _declarationTContainer: TContainerNode,
|
||||
public elementRef: ElementRef) {
|
||||
super();
|
||||
}
|
||||
|
||||
createEmbeddedView(context: T): EmbeddedViewRef<T> {
|
||||
const embeddedTView = this._declarationTContainer.tViews as TView;
|
||||
const embeddedLView = createLView(
|
||||
this._declarationLView, embeddedTView, context, LViewFlags.CheckAlways, null,
|
||||
embeddedTView.declTNode, null, null, null, null);
|
||||
|
||||
const declarationLContainer = this._declarationLView[this._declarationTContainer.index];
|
||||
ngDevMode && assertLContainer(declarationLContainer);
|
||||
embeddedLView[DECLARATION_LCONTAINER] = declarationLContainer;
|
||||
|
||||
const declarationViewLQueries = this._declarationLView[QUERIES];
|
||||
if (declarationViewLQueries !== null) {
|
||||
embeddedLView[QUERIES] = declarationViewLQueries.createEmbeddedView(embeddedTView);
|
||||
}
|
||||
|
||||
renderView(embeddedTView, embeddedLView, context);
|
||||
|
||||
return new R3_ViewRef<T>(embeddedLView);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Creates a TemplateRef given a node.
|
||||
*
|
||||
* @returns The TemplateRef instance to use
|
||||
*/
|
||||
export function injectTemplateRef<T>(): TemplateRef<T>|null {
|
||||
return createTemplateRef<T>(getCurrentTNode()!, getLView());
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a TemplateRef and stores it on the injector.
|
||||
*
|
||||
* @param hostTNode The node on which a TemplateRef is requested
|
||||
* @param hostLView The `LView` to which the node belongs
|
||||
* @returns The TemplateRef instance or null if we can't create a TemplateRef on a given node type
|
||||
*/
|
||||
export function createTemplateRef<T>(hostTNode: TNode, hostLView: LView): TemplateRef<T>|null {
|
||||
if (hostTNode.type & TNodeType.Container) {
|
||||
ngDevMode && assertDefined(hostTNode.tViews, 'TView must be allocated');
|
||||
return new R3TemplateRef(
|
||||
hostLView, hostTNode as TContainerNode, createElementRef(hostTNode, hostLView));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ import {InjectionToken} from '../di/injection_token';
|
|||
import {Type} from '../interface/type';
|
||||
import {createElementRef, ElementRef as ViewEngine_ElementRef} from '../linker/element_ref';
|
||||
import {QueryList} from '../linker/query_list';
|
||||
import {TemplateRef as ViewEngine_TemplateRef} from '../linker/template_ref';
|
||||
import {createTemplateRef, TemplateRef as ViewEngine_TemplateRef} from '../linker/template_ref';
|
||||
import {ViewContainerRef} from '../linker/view_container_ref';
|
||||
import {assertDefined, assertIndexInRange, throwError} from '../util/assert';
|
||||
import {stringify} from '../util/stringify';
|
||||
|
@ -30,7 +30,7 @@ import {DECLARATION_LCONTAINER, LView, PARENT, QUERIES, TVIEW, TView} from './in
|
|||
import {assertTNodeType} from './node_assert';
|
||||
import {getCurrentQueryIndex, getCurrentTNode, getLView, getTView, setCurrentQueryIndex} from './state';
|
||||
import {isCreationMode} from './util/view_utils';
|
||||
import {createContainerRef, createTemplateRef} from './view_engine_compatibility';
|
||||
import {createContainerRef} from './view_engine_compatibility';
|
||||
|
||||
const unusedValueToPlacateAjd = unused1 + unused2 + unused3 + unused4;
|
||||
|
||||
|
@ -302,7 +302,7 @@ function createResultByTNodeType(tNode: TNode, currentView: LView): any {
|
|||
if (tNode.type & (TNodeType.AnyRNode | TNodeType.ElementContainer)) {
|
||||
return createElementRef(tNode, currentView);
|
||||
} else if (tNode.type & TNodeType.Container) {
|
||||
return createTemplateRef(ViewEngine_TemplateRef, tNode, currentView);
|
||||
return createTemplateRef(tNode, currentView);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -325,7 +325,7 @@ function createSpecialToken(lView: LView, tNode: TNode, read: any): any {
|
|||
if (read === ViewEngine_ElementRef) {
|
||||
return createElementRef(tNode, lView);
|
||||
} else if (read === ViewEngine_TemplateRef) {
|
||||
return createTemplateRef(ViewEngine_TemplateRef, tNode, lView);
|
||||
return createTemplateRef(tNode, lView);
|
||||
} else if (read === ViewContainerRef) {
|
||||
ngDevMode && assertTNodeType(tNode, TNodeType.AnyRNode | TNodeType.AnyContainer);
|
||||
return createContainerRef(
|
||||
|
|
|
@ -16,17 +16,17 @@ import {ViewContainerRef as ViewEngine_ViewContainerRef} from '../linker/view_co
|
|||
import {EmbeddedViewRef as viewEngine_EmbeddedViewRef, ViewRef as viewEngine_ViewRef} from '../linker/view_ref';
|
||||
import {Renderer2} from '../render/api';
|
||||
import {addToArray, removeFromArray} from '../util/array_utils';
|
||||
import {assertDefined, assertEqual, assertGreaterThan, assertLessThan} from '../util/assert';
|
||||
import {assertEqual, assertGreaterThan, assertLessThan} from '../util/assert';
|
||||
|
||||
import {assertLContainer, assertNodeInjector} from './assert';
|
||||
import {assertNodeInjector} from './assert';
|
||||
import {getParentInjectorLocation, NodeInjector} from './di';
|
||||
import {addToViewTree, createLContainer, createLView, renderView} from './instructions/shared';
|
||||
import {addToViewTree, createLContainer} from './instructions/shared';
|
||||
import {CONTAINER_HEADER_OFFSET, LContainer, NATIVE, VIEW_REFS} from './interfaces/container';
|
||||
import {NodeInjectorOffset} from './interfaces/injector';
|
||||
import {TContainerNode, TDirectiveHostNode, TElementContainerNode, TElementNode, TNode, TNodeType} from './interfaces/node';
|
||||
import {isProceduralRenderer, RComment, RElement} from './interfaces/renderer';
|
||||
import {isComponentHost, isLContainer, isLView} from './interfaces/type_checks';
|
||||
import {DECLARATION_COMPONENT_VIEW, DECLARATION_LCONTAINER, LView, LViewFlags, PARENT, QUERIES, RENDERER, T_HOST, TVIEW, TView} from './interfaces/view';
|
||||
import {DECLARATION_COMPONENT_VIEW, LView, PARENT, RENDERER, T_HOST, TVIEW} from './interfaces/view';
|
||||
import {assertTNodeType} from './node_assert';
|
||||
import {addViewToContainer, destroyLView, detachView, getBeforeNodeForView, insertView, nativeInsertBefore, nativeNextSibling, nativeParentNode} from './node_manipulation';
|
||||
import {getCurrentTNode, getLView} from './state';
|
||||
|
@ -36,72 +36,6 @@ import {ViewRef} from './view_ref';
|
|||
|
||||
|
||||
|
||||
let R3TemplateRef: {
|
||||
new (_declarationParentView: LView, hostTNode: TContainerNode, elementRef: ViewEngine_ElementRef):
|
||||
ViewEngine_TemplateRef<any>
|
||||
};
|
||||
|
||||
/**
|
||||
* Creates a TemplateRef given a node.
|
||||
*
|
||||
* @returns The TemplateRef instance to use
|
||||
*/
|
||||
export function injectTemplateRef<T>(TemplateRefToken: typeof ViewEngine_TemplateRef):
|
||||
ViewEngine_TemplateRef<T>|null {
|
||||
return createTemplateRef<T>(TemplateRefToken, getCurrentTNode()!, getLView());
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a TemplateRef and stores it on the injector.
|
||||
*
|
||||
* @param TemplateRefToken The TemplateRef type
|
||||
* @param ElementRefToken The ElementRef type
|
||||
* @param hostTNode The node on which a TemplateRef is requested
|
||||
* @param hostView The view to which the node belongs
|
||||
* @returns The TemplateRef instance or null if we can't create a TemplateRef on a given node type
|
||||
*/
|
||||
export function createTemplateRef<T>(
|
||||
TemplateRefToken: typeof ViewEngine_TemplateRef, hostTNode: TNode,
|
||||
hostView: LView): ViewEngine_TemplateRef<T>|null {
|
||||
if (!R3TemplateRef) {
|
||||
R3TemplateRef = class TemplateRef<T> extends TemplateRefToken<T>{
|
||||
constructor(
|
||||
private _declarationView: LView, private _declarationTContainer: TContainerNode,
|
||||
readonly elementRef: ViewEngine_ElementRef) {
|
||||
super();
|
||||
}
|
||||
|
||||
createEmbeddedView(context: T): viewEngine_EmbeddedViewRef<T> {
|
||||
const embeddedTView = this._declarationTContainer.tViews as TView;
|
||||
const embeddedLView = createLView(
|
||||
this._declarationView, embeddedTView, context, LViewFlags.CheckAlways, null,
|
||||
embeddedTView.declTNode, null, null, null, null);
|
||||
|
||||
const declarationLContainer = this._declarationView[this._declarationTContainer.index];
|
||||
ngDevMode && assertLContainer(declarationLContainer);
|
||||
embeddedLView[DECLARATION_LCONTAINER] = declarationLContainer;
|
||||
|
||||
const declarationViewLQueries = this._declarationView[QUERIES];
|
||||
if (declarationViewLQueries !== null) {
|
||||
embeddedLView[QUERIES] = declarationViewLQueries.createEmbeddedView(embeddedTView);
|
||||
}
|
||||
|
||||
renderView(embeddedTView, embeddedLView, context);
|
||||
|
||||
return new ViewRef<T>(embeddedLView);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
if (hostTNode.type & TNodeType.Container) {
|
||||
ngDevMode && assertDefined(hostTNode.tViews, 'TView must be allocated');
|
||||
return new R3TemplateRef(
|
||||
hostView, hostTNode as TContainerNode, createElementRef(hostTNode, hostView));
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
let R3ViewContainerRef: {
|
||||
new (
|
||||
lContainer: LContainer, hostTNode: TElementNode|TContainerNode|TElementContainerNode,
|
||||
|
|
|
@ -9,11 +9,11 @@
|
|||
|
||||
import {ChangeDetectorRef} from '../change_detection/change_detector_ref';
|
||||
import {InjectFlags} from '../di/interface/injector';
|
||||
import {TemplateRef as ViewEngine_TemplateRef} from '../linker/template_ref';
|
||||
import {createTemplateRef, TemplateRef} from '../linker/template_ref';
|
||||
import {throwProviderNotFoundError} from './errors';
|
||||
import {TNode} from './interfaces/node';
|
||||
import {LView} from './interfaces/view';
|
||||
import {createTemplateRef, injectChangeDetectorRef} from './view_engine_compatibility';
|
||||
import {injectChangeDetectorRef} from './view_engine_compatibility';
|
||||
|
||||
|
||||
/**
|
||||
|
@ -22,8 +22,8 @@ import {createTemplateRef, injectChangeDetectorRef} from './view_engine_compatib
|
|||
*
|
||||
* @codeGenApi
|
||||
*/
|
||||
export function ɵɵtemplateRefExtractor(tNode: TNode, currentView: LView) {
|
||||
return createTemplateRef(ViewEngine_TemplateRef, tNode, currentView);
|
||||
export function ɵɵtemplateRefExtractor(tNode: TNode, lView: LView): TemplateRef<any>|null {
|
||||
return createTemplateRef(tNode, lView);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -467,6 +467,9 @@
|
|||
{
|
||||
"name": "R3Injector"
|
||||
},
|
||||
{
|
||||
"name": "R3TemplateRef"
|
||||
},
|
||||
{
|
||||
"name": "RADIO_VALUE_ACCESSOR"
|
||||
},
|
||||
|
@ -620,6 +623,9 @@
|
|||
{
|
||||
"name": "VERSION"
|
||||
},
|
||||
{
|
||||
"name": "ViewEngineTemplateRef"
|
||||
},
|
||||
{
|
||||
"name": "Validators"
|
||||
},
|
||||
|
|
|
@ -572,6 +572,9 @@
|
|||
{
|
||||
"name": "R3Injector"
|
||||
},
|
||||
{
|
||||
"name": "R3TemplateRef"
|
||||
},
|
||||
{
|
||||
"name": "ROUTER_CONFIGURATION"
|
||||
},
|
||||
|
@ -839,6 +842,9 @@
|
|||
{
|
||||
"name": "VERSION"
|
||||
},
|
||||
{
|
||||
"name": "ViewEngineTemplateRef"
|
||||
},
|
||||
{
|
||||
"name": "Version"
|
||||
},
|
||||
|
|
|
@ -86,6 +86,9 @@
|
|||
{
|
||||
"name": "Optional"
|
||||
},
|
||||
{
|
||||
"name": "R3TemplateRef"
|
||||
},
|
||||
{
|
||||
"name": "RecordViewTuple"
|
||||
},
|
||||
|
@ -134,6 +137,9 @@
|
|||
{
|
||||
"name": "TodoStore"
|
||||
},
|
||||
{
|
||||
"name": "ViewEngineTemplateRef"
|
||||
},
|
||||
{
|
||||
"name": "ViewContainerRef"
|
||||
},
|
||||
|
|
|
@ -5,23 +5,25 @@
|
|||
* Use of this source code is governed by an MIT-style license that can be
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
import {injectTemplateRef} from '@angular/core/src/linker/template_ref';
|
||||
import {TemplateRef, ViewContainerRef} from '../../../../src/linker';
|
||||
import {ɵɵdefineDirective, ɵɵdirectiveInject, ɵɵtemplate} from '../../../../src/render3/index';
|
||||
import {createLView, createTNode, createTView} from '../../../../src/render3/instructions/shared';
|
||||
import {RenderFlags} from '../../../../src/render3/interfaces/definition';
|
||||
import {TNodeType} from '../../../../src/render3/interfaces/node';
|
||||
import {LViewFlags, TViewType} from '../../../../src/render3/interfaces/view';
|
||||
import {injectTemplateRef, injectViewContainerRef} from '../../../../src/render3/view_engine_compatibility';
|
||||
import {injectViewContainerRef} from '../../../../src/render3/view_engine_compatibility';
|
||||
import {createBenchmark} from '../micro_bench';
|
||||
import {createAndRenderLView} from '../setup';
|
||||
|
||||
|
||||
class TemplateRefToken {
|
||||
/**
|
||||
* @internal
|
||||
* @nocollapse
|
||||
*/
|
||||
static __NG_ELEMENT_ID__(): TemplateRef<any>|null {
|
||||
return injectTemplateRef(TemplateRef);
|
||||
return injectTemplateRef();
|
||||
}
|
||||
}
|
||||
class ViewContainerRefToken {
|
||||
|
|
|
@ -453,7 +453,7 @@ export const text: RText = null as any as Text;
|
|||
*/
|
||||
export function enableIvyInjectableFactories() {
|
||||
(ElementRef as any)[NG_ELEMENT_ID] = () => R3_ELEMENT_REF_FACTORY();
|
||||
(TemplateRef as any)[NG_ELEMENT_ID] = () => R3_TEMPLATE_REF_FACTORY(TemplateRef);
|
||||
(TemplateRef as any)[NG_ELEMENT_ID] = () => R3_TEMPLATE_REF_FACTORY();
|
||||
(ViewContainerRef as any)[NG_ELEMENT_ID] = () => R3_VIEW_CONTAINER_REF_FACTORY(ViewContainerRef);
|
||||
(ChangeDetectorRef as any)[NG_ELEMENT_ID] = () => R3_CHANGE_DETECTOR_REF_FACTORY();
|
||||
(Renderer2 as any)[NG_ELEMENT_ID] = () => R3_RENDERER2_FACTORY();
|
||||
|
|
Loading…
Reference in New Issue