@@ -12,7 +12,7 @@ import {TContainerNode, TNode, TNodeType} from '../render3/interfaces/node';
1212import { LView } from '../render3/interfaces/view' ;
1313import { getCurrentTNode , getLView } from '../render3/state' ;
1414import { createAndRenderEmbeddedLView } from '../render3/view_manipulation' ;
15- import { ViewRef as R3_ViewRef } from '../render3/view_ref' ;
15+ import { ViewRef } from '../render3/view_ref' ;
1616import { assertDefined } from '../util/assert' ;
1717
1818import { createElementRef , ElementRef } from './element_ref' ;
@@ -35,7 +35,7 @@ import {EmbeddedViewRef} from './view_ref';
3535 *
3636 * @publicApi
3737 */
38- export abstract class TemplateRef < C > {
38+ export class TemplateRef < C > {
3939 /**
4040 * The anchor element in the parent view for this embedded view.
4141 *
@@ -47,59 +47,21 @@ export abstract class TemplateRef<C> {
4747 * data-binding and injection context from the original location.
4848 *
4949 */
50- // TODO(i): rename to anchor or location
51- abstract readonly elementRef : ElementRef ;
52-
53- /**
54- * Instantiates an unattached embedded view based on this template.
55- * @param context The data-binding context of the embedded view, as declared
56- * in the `<ng-template>` usage.
57- * @param injector Injector to be used within the embedded view.
58- * @returns The new embedded view object.
59- */
60- abstract createEmbeddedView ( context : C , injector ?: Injector ) : EmbeddedViewRef < C > ;
61-
62- /**
63- * Implementation of the `createEmbeddedView` function.
64- *
65- * This implementation is internal and allows framework code
66- * to invoke it with extra parameters (e.g. for hydration) without
67- * affecting public API.
68- *
69- * @internal
70- */
71- abstract createEmbeddedViewImpl (
72- context : C ,
73- injector ?: Injector ,
74- dehydratedView ?: DehydratedContainerView | null ,
75- ) : EmbeddedViewRef < C > ;
76-
77- /**
78- * Returns an `ssrId` associated with a TView, which was used to
79- * create this instance of the `TemplateRef`.
80- *
81- * @internal
82- */
83- abstract get ssrId ( ) : string | null ;
50+ readonly elementRef : ElementRef ;
8451
8552 /**
8653 * @internal
8754 * @nocollapse
8855 */
8956 static __NG_ELEMENT_ID__ : ( ) => TemplateRef < any > | null = injectTemplateRef ;
90- }
9157
92- const ViewEngineTemplateRef = TemplateRef ;
93-
94- // TODO(alxhub): combine interface and implementation. Currently this is challenging since something
95- // in g3 depends on them being separate.
96- const R3TemplateRef = class TemplateRef < T > extends ViewEngineTemplateRef < T > {
58+ /** @internal */
9759 constructor (
9860 private _declarationLView : LView ,
9961 private _declarationTContainer : TContainerNode ,
100- public override elementRef : ElementRef ,
62+ elementRef : ElementRef ,
10163 ) {
102- super ( ) ;
64+ this . elementRef = elementRef ;
10365 }
10466
10567 /**
@@ -108,31 +70,44 @@ const R3TemplateRef = class TemplateRef<T> extends ViewEngineTemplateRef<T> {
10870 *
10971 * @internal
11072 */
111- override get ssrId ( ) : string | null {
73+ get ssrId ( ) : string | null {
11274 return this . _declarationTContainer . tView ?. ssrId || null ;
11375 }
11476
115- override createEmbeddedView ( context : T , injector ?: Injector ) : EmbeddedViewRef < T > {
77+ /**
78+ * Instantiates an unattached embedded view based on this template.
79+ * @param context The data-binding context of the embedded view, as declared
80+ * in the `<ng-template>` usage.
81+ * @param injector Injector to be used within the embedded view.
82+ * @returns The new embedded view object.
83+ */
84+ createEmbeddedView ( context : C , injector ?: Injector ) : EmbeddedViewRef < C > {
11685 return this . createEmbeddedViewImpl ( context , injector ) ;
11786 }
11887
11988 /**
89+ * Implementation of the `createEmbeddedView` function.
90+ *
91+ * This implementation is internal and allows framework code
92+ * to invoke it with extra parameters (e.g. for hydration) without
93+ * affecting public API.
94+ *
12095 * @internal
12196 */
122- override createEmbeddedViewImpl (
123- context : T ,
97+ createEmbeddedViewImpl (
98+ context : C ,
12499 injector ?: Injector ,
125- dehydratedView ?: DehydratedContainerView ,
126- ) : EmbeddedViewRef < T > {
100+ dehydratedView ?: DehydratedContainerView | null ,
101+ ) : EmbeddedViewRef < C > {
127102 const embeddedLView = createAndRenderEmbeddedLView (
128103 this . _declarationLView ,
129104 this . _declarationTContainer ,
130105 context ,
131106 { embeddedViewInjector : injector , dehydratedView} ,
132107 ) ;
133- return new R3_ViewRef < T > ( embeddedLView ) ;
108+ return new ViewRef < C > ( embeddedLView ) ;
134109 }
135- } ;
110+ }
136111
137112/**
138113 * Creates a TemplateRef given a node.
@@ -153,7 +128,7 @@ export function injectTemplateRef<T>(): TemplateRef<T> | null {
153128export function createTemplateRef < T > ( hostTNode : TNode , hostLView : LView ) : TemplateRef < T > | null {
154129 if ( hostTNode . type & TNodeType . Container ) {
155130 ngDevMode && assertDefined ( hostTNode . tView , 'TView must be allocated' ) ;
156- return new R3TemplateRef (
131+ return new TemplateRef (
157132 hostLView ,
158133 hostTNode as TContainerNode ,
159134 createElementRef ( hostTNode , hostLView ) ,
0 commit comments