@@ -548,29 +548,13 @@ function saveResolvedLocalsInData(
548
548
* Gets TView from a template function or creates a new TView
549
549
* if it doesn't already exist.
550
550
*
551
- * @param templateFn The template from which to get static data
552
- * @param consts The number of nodes, local refs, and pipes in this view
553
- * @param vars The number of bindings and pure function bindings in this view
554
- * @param directives Directive defs that should be saved on TView
555
- * @param pipes Pipe defs that should be saved on TView
556
- * @param viewQuery View query that should be saved on TView
557
- * @param schemas Schemas that should be saved on TView
551
+ * @param def ComponentDef
558
552
* @returns TView
559
553
*/
560
- export function getOrCreateTView (
561
- templateFn : ComponentTemplate < any > , consts : number , vars : number ,
562
- directives : DirectiveDefListOrFactory | null , pipes : PipeDefListOrFactory | null ,
563
- viewQuery : ViewQueriesFunction < any > | null , schemas : SchemaMetadata [ ] | null ) : TView {
564
- // TODO(misko): reading `ngPrivateData` here is problematic for two reasons
565
- // 1. It is a megamorphic call on each invocation.
566
- // 2. For nested embedded views (ngFor inside ngFor) the template instance is per
567
- // outer template invocation, which means that no such property will exist
568
- // Correct solution is to only put `ngPrivateData` on the Component template
569
- // and not on embedded templates.
570
-
571
- return templateFn . ngPrivateData ||
572
- ( templateFn . ngPrivateData = createTView (
573
- - 1 , templateFn , consts , vars , directives , pipes , viewQuery , schemas ) as never ) ;
554
+ export function getOrCreateTView ( def : ComponentDef < any > ) : TView {
555
+ return def . tView || ( def . tView = createTView (
556
+ - 1 , def . template , def . consts , def . vars , def . directiveDefs , def . pipeDefs ,
557
+ def . viewQuery , def . schemas ) ) ;
574
558
}
575
559
576
560
/**
@@ -1262,9 +1246,7 @@ function addComponentLogic<T>(
1262
1246
lView : LView , previousOrParentTNode : TNode , def : ComponentDef < T > ) : void {
1263
1247
const native = getNativeByTNode ( previousOrParentTNode , lView ) ;
1264
1248
1265
- const tView = getOrCreateTView (
1266
- def . template , def . consts , def . vars , def . directiveDefs , def . pipeDefs , def . viewQuery ,
1267
- def . schemas ) ;
1249
+ const tView = getOrCreateTView ( def ) ;
1268
1250
1269
1251
// Only component views should be added to the view tree directly. Embedded views are
1270
1252
// accessed through their containers because they may be removed / re-added later.
0 commit comments