refactor(ivy): remove need for LContainer.template (#24335)
PR Close #24335
This commit is contained in:
		
							parent
							
								
									bd02b27ee1
								
							
						
					
					
						commit
						f781f741ea
					
				| @ -572,7 +572,7 @@ export function getOrCreateContainerRef(di: LInjector): viewEngine_ViewContainer | |||||||
| 
 | 
 | ||||||
|     ngDevMode && assertNodeOfPossibleTypes(vcRefHost, TNodeType.Container, TNodeType.Element); |     ngDevMode && assertNodeOfPossibleTypes(vcRefHost, TNodeType.Container, TNodeType.Element); | ||||||
|     const hostParent = getParentLNode(vcRefHost) !; |     const hostParent = getParentLNode(vcRefHost) !; | ||||||
|     const lContainer = createLContainer(hostParent, vcRefHost.view, undefined, true); |     const lContainer = createLContainer(hostParent, vcRefHost.view, true); | ||||||
|     const lContainerNode: LContainerNode = createLNodeObject( |     const lContainerNode: LContainerNode = createLNodeObject( | ||||||
|         TNodeType.Container, vcRefHost.view, hostParent, undefined, lContainer, null); |         TNodeType.Container, vcRefHost.view, hostParent, undefined, lContainer, null); | ||||||
| 
 | 
 | ||||||
| @ -702,11 +702,6 @@ export function getOrCreateTemplateRef<T>(di: LInjector): viewEngine_TemplateRef | |||||||
|     ngDevMode && assertNodeType(di.node, TNodeType.Container); |     ngDevMode && assertNodeType(di.node, TNodeType.Container); | ||||||
|     const hostNode = di.node as LContainerNode; |     const hostNode = di.node as LContainerNode; | ||||||
|     const hostTNode = hostNode.tNode; |     const hostTNode = hostNode.tNode; | ||||||
|     const hostTView = hostNode.view.tView; |  | ||||||
|     if (!hostTNode.tViews) { |  | ||||||
|       hostTNode.tViews = createTView( |  | ||||||
|           -1, hostNode.data.template !, hostTView.directiveRegistry, hostTView.pipeRegistry); |  | ||||||
|     } |  | ||||||
|     ngDevMode && assertDefined(hostTNode.tViews, 'TView must be allocated'); |     ngDevMode && assertDefined(hostTNode.tViews, 'TView must be allocated'); | ||||||
|     di.templateRef = new TemplateRef<any>( |     di.templateRef = new TemplateRef<any>( | ||||||
|         getOrCreateElementRef(di), hostTNode.tViews as TView, getRenderer(), hostNode.data.queries); |         getOrCreateElementRef(di), hostTNode.tViews as TView, getRenderer(), hostNode.data.queries); | ||||||
|  | |||||||
| @ -1494,8 +1494,7 @@ function generateInitialInputs( | |||||||
|  * @returns LContainer |  * @returns LContainer | ||||||
|  */ |  */ | ||||||
| export function createLContainer( | export function createLContainer( | ||||||
|     parentLNode: LNode, currentView: LView, template?: ComponentTemplate<any>, |     parentLNode: LNode, currentView: LView, isForViewContainerRef?: boolean): LContainer { | ||||||
|     isForViewContainerRef?: boolean): LContainer { |  | ||||||
|   ngDevMode && assertDefined(parentLNode, 'containers should have a parent'); |   ngDevMode && assertDefined(parentLNode, 'containers should have a parent'); | ||||||
|   return <LContainer>{ |   return <LContainer>{ | ||||||
|     views: [], |     views: [], | ||||||
| @ -1503,7 +1502,6 @@ export function createLContainer( | |||||||
|     // If the direct parent of the container is a view, its views will need to be added
 |     // If the direct parent of the container is a view, its views will need to be added
 | ||||||
|     // through insertView() when its parent view is being inserted:
 |     // through insertView() when its parent view is being inserted:
 | ||||||
|     renderParent: canInsertNativeNode(parentLNode, currentView) ? parentLNode : null, |     renderParent: canInsertNativeNode(parentLNode, currentView) ? parentLNode : null, | ||||||
|     template: template == null ? null : template, |  | ||||||
|     next: null, |     next: null, | ||||||
|     parent: currentView, |     parent: currentView, | ||||||
|     queries: null |     queries: null | ||||||
| @ -1529,12 +1527,16 @@ export function container( | |||||||
|           currentView.bindingIndex, -1, 'container nodes should be created before any bindings'); |           currentView.bindingIndex, -1, 'container nodes should be created before any bindings'); | ||||||
| 
 | 
 | ||||||
|   const currentParent = isParent ? previousOrParentNode : getParentLNode(previousOrParentNode) !; |   const currentParent = isParent ? previousOrParentNode : getParentLNode(previousOrParentNode) !; | ||||||
|   const lContainer = createLContainer(currentParent, currentView, template); |   const lContainer = createLContainer(currentParent, currentView); | ||||||
| 
 | 
 | ||||||
|   const node = createLNode( |   const node = createLNode( | ||||||
|       index, TNodeType.Container, undefined, tagName || null, attrs || null, lContainer); |       index, TNodeType.Container, undefined, tagName || null, attrs || null, lContainer); | ||||||
| 
 | 
 | ||||||
|   if (firstTemplatePass && template == null) node.tNode.tViews = []; |   if (firstTemplatePass) { | ||||||
|  |     const tView = currentView.tView; | ||||||
|  |     node.tNode.tViews = | ||||||
|  |         template ? createTView(-1, template, tView.directiveRegistry, tView.pipeRegistry) : []; | ||||||
|  |   } | ||||||
| 
 | 
 | ||||||
|   // Containers are added to the current view tree instead of their embedded views
 |   // Containers are added to the current view tree instead of their embedded views
 | ||||||
|   // because views can be removed and re-inserted.
 |   // because views can be removed and re-inserted.
 | ||||||
|  | |||||||
| @ -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 {ComponentTemplate} from './definition'; |  | ||||||
| import {LContainerNode, LElementNode, LViewNode} from './node'; | import {LContainerNode, LElementNode, LViewNode} from './node'; | ||||||
| import {LQueries} from './query'; | import {LQueries} from './query'; | ||||||
| import {LView, TView} from './view'; | import {LView, TView} from './view'; | ||||||
| @ -67,11 +66,6 @@ export interface LContainer { | |||||||
|    */ |    */ | ||||||
|   renderParent: LElementNode|null; |   renderParent: LElementNode|null; | ||||||
| 
 | 
 | ||||||
|   /** |  | ||||||
|    * The template extracted from the location of the Container. |  | ||||||
|    */ |  | ||||||
|   readonly template: ComponentTemplate<any>|null; |  | ||||||
| 
 |  | ||||||
|   /** |   /** | ||||||
|    * Queries active for this container - all the views inserted to / removed from |    * Queries active for this container - all the views inserted to / removed from | ||||||
|    * this container are reported to queries referenced here. |    * this container are reported to queries referenced here. | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user