fix(ivy): only generate TViews once per embedded template (#23385)

PR Close #23385
This commit is contained in:
Kara Erickson
2018-04-26 10:44:49 -07:00
committed by Igor Minar
parent b76f5a6a7d
commit c5cfc3a1b6
8 changed files with 117 additions and 101 deletions

View File

@ -82,24 +82,6 @@ export interface LContainer {
queries: LQueries|null;
}
/**
* The static equivalent of LContainer, used in TContainerNode.
*
* The container needs to store static data for each of its embedded views
* (TViews). Otherwise, nodes in embedded views with the same index as nodes
* in their parent views will overwrite each other, as they are in
* the same template.
*
* Each index in this array corresponds to the static data for a certain
* view. So if you had V(0) and V(1) in a container, you might have:
*
* [
* [{tagName: 'div', attrs: ...}, null], // V(0) TView
* [{tagName: 'button', attrs ...}, null] // V(1) TView
* ]
*/
export type TContainer = TView[];
// Note: This hack is necessary so we don't erroneously get a circular dependency
// failure based on types.
export const unusedValueExportToPlacateAjd = 1;

View File

@ -6,7 +6,7 @@
* found in the LICENSE file at https://angular.io/license
*/
import {LContainer, TContainer} from './container';
import {LContainer} from './container';
import {LInjector} from './injector';
import {LProjection} from './projection';
import {LQueries} from './query';
@ -283,21 +283,33 @@ export interface TNode {
outputs: PropertyAliases|null|undefined;
/**
* The static data equivalent of LNode.data.
* The TView or TViews attached to this node.
*
* If this TNode corresponds to an LContainerNode, the container will
* need to store separate static data for each of its views (TContainer).
* If this TNode corresponds to an LContainerNode with inline views, the container will
* need to store separate static data for each of its view blocks (TView[]). Otherwise,
* nodes in inline views with the same index as nodes in their parent views will overwrite
* each other, as they are in the same template.
*
* If this TNode corresponds to an LElementNode, data will be null.
* Each index in this array corresponds to the static data for a certain
* view. So if you had V(0) and V(1) in a container, you might have:
*
* [
* [{tagName: 'div', attrs: ...}, null], // V(0) TView
* [{tagName: 'button', attrs ...}, null] // V(1) TView
*
* If this TNode corresponds to an LContainerNode with a template (e.g. structural
* directive), the template's TView will be stored here.
*
* If this TNode corresponds to an LElementNode, tViews will be null .
*/
data: TContainer|null;
tViews: TView|TView[]|null;
}
/** Static data for an LElementNode */
export interface TElementNode extends TNode { data: null; }
export interface TElementNode extends TNode { tViews: null; }
/** Static data for an LContainerNode */
export interface TContainerNode extends TNode { data: TContainer; }
export interface TContainerNode extends TNode { tViews: TView|TView[]|null; }
/**
* This mapping is necessary so we can set input properties and output listeners