diff --git a/packages/core/src/render3/i18n.ts b/packages/core/src/render3/i18n.ts index f9450906d0..1705d55c4a 100644 --- a/packages/core/src/render3/i18n.ts +++ b/packages/core/src/render3/i18n.ts @@ -277,7 +277,6 @@ function appendI18nNode( // Template containers also have a comment node for the `ViewContainerRef` that should be moved if (tNode.type === TNodeType.Container && node.dynamicLContainerNode) { appendChild(node.dynamicLContainerNode.native, tNode, viewData); - return tNode.dynamicContainerNode !; } return tNode; @@ -376,7 +375,7 @@ export function i18nApply(startIndex: number, instructions: I18nInstruction[]): // For template containers we also need to remove their `ViewContainerRef` from the DOM if (removedTNode.type === TNodeType.Container && removedNode.dynamicLContainerNode) { removeChild(removedTNode, removedNode.dynamicLContainerNode.native || null, viewData); - removedTNode.dynamicContainerNode !.detached = true; + removedTNode.detached = true; removedNode.dynamicLContainerNode.data[RENDER_PARENT] = null; } break; diff --git a/packages/core/src/render3/instructions.ts b/packages/core/src/render3/instructions.ts index 4d77046cfd..27ceed2098 100644 --- a/packages/core/src/render3/instructions.ts +++ b/packages/core/src/render3/instructions.ts @@ -496,8 +496,6 @@ export function createNodeAtIndex( createTNode(type, adjustedIndex, name, attrs, tParent, null); if (!isParent && previousOrParentTNode) { previousOrParentTNode.next = tNode; - if (previousOrParentTNode.dynamicContainerNode) - previousOrParentTNode.dynamicContainerNode.next = tNode; } } @@ -1518,7 +1516,6 @@ export function createTNode( next: null, child: null, parent: parent, - dynamicContainerNode: null, detached: null, stylingTemplate: null, projection: null diff --git a/packages/core/src/render3/interfaces/node.ts b/packages/core/src/render3/interfaces/node.ts index 112572ad16..e004561e28 100644 --- a/packages/core/src/render3/interfaces/node.ts +++ b/packages/core/src/render3/interfaces/node.ts @@ -325,11 +325,6 @@ export interface TNode { */ parent: TElementNode|TContainerNode|null; - /** - * A pointer to a TContainerNode created by directives requesting ViewContainerRef - */ - dynamicContainerNode: TNode|null; - /** * If this node is part of an i18n block, it indicates whether this container is part of the DOM * If this node is not part of an i18n block, this field is null. diff --git a/packages/core/src/render3/node_manipulation.ts b/packages/core/src/render3/node_manipulation.ts index 1a518f4b42..4484175870 100644 --- a/packages/core/src/render3/node_manipulation.ts +++ b/packages/core/src/render3/node_manipulation.ts @@ -10,7 +10,7 @@ import {assertDefined} from './assert'; import {attachPatchData, readElementValue} from './context_discovery'; import {callHooks} from './hooks'; import {LContainer, RENDER_PARENT, VIEWS, unusedValueExportToPlacateAjd as unused1} from './interfaces/container'; -import {LContainerNode, LElementContainerNode, LElementNode, LTextNode, TContainerNode, TElementNode, TNode, TNodeFlags, TNodeType, TViewNode, unusedValueExportToPlacateAjd as unused2} from './interfaces/node'; +import {LContainerNode, LElementContainerNode, LElementNode, LTextNode, TContainerNode, TElementContainerNode, TElementNode, TNode, TNodeFlags, TNodeType, TViewNode, unusedValueExportToPlacateAjd as unused2} from './interfaces/node'; import {unusedValueExportToPlacateAjd as unused3} from './interfaces/projection'; import {ProceduralRenderer3, RComment, RElement, RNode, RText, Renderer3, isProceduralRenderer, unusedValueExportToPlacateAjd as unused4} from './interfaces/renderer'; import {CLEANUP, CONTAINER_INDEX, FLAGS, HEADER_OFFSET, HOST_NODE, HookData, LViewData, LViewFlags, NEXT, PARENT, QUERIES, RENDERER, TVIEW, unusedValueExportToPlacateAjd as unused5} from './interfaces/view'; @@ -393,9 +393,10 @@ export function detachView(lContainer: LContainer, removeIndex: number, detached * @param removeIndex The index of the view to remove */ export function removeView( - lContainer: LContainer, tContainer: TContainerNode, removeIndex: number) { + lContainer: LContainer, containerHost: TElementNode | TContainerNode | TElementContainerNode, + removeIndex: number) { const view = lContainer[VIEWS][removeIndex]; - detachView(lContainer, removeIndex, !!tContainer.detached); + detachView(lContainer, removeIndex, !!containerHost.detached); destroyLView(view); } diff --git a/packages/core/src/render3/view_engine_compatibility.ts b/packages/core/src/render3/view_engine_compatibility.ts index 4795365328..b24f076c1d 100644 --- a/packages/core/src/render3/view_engine_compatibility.ts +++ b/packages/core/src/render3/view_engine_compatibility.ts @@ -105,13 +105,14 @@ export function createTemplateRef( } createEmbeddedView( - context: T, container?: LContainer, tContainerNode?: TContainerNode, hostView?: LViewData, + context: T, container?: LContainer, + hostTNode?: TElementNode|TContainerNode|TElementContainerNode, hostView?: LViewData, index?: number): viewEngine_EmbeddedViewRef { const lView = createEmbeddedViewAndNode( this._tView, context, this._declarationParentView, this._renderer, this._queries, this._injectorIndex); if (container) { - insertView(lView, container, hostView !, index !, tContainerNode !.parent !.index); + insertView(lView, container, hostView !, index !, hostTNode !.index); } renderEmbeddedTemplate(lView, this._tView, context, RenderFlags.Create); const viewRef = new ViewRef(lView, context, -1); @@ -132,9 +133,8 @@ export function createTemplateRef( let R3ViewContainerRef: { new ( - lContainer: LContainer, tContainerNode: TContainerNode, - hostTNode: TElementNode | TContainerNode | TElementContainerNode, hostView: LViewData): - ViewEngine_ViewContainerRef + lContainer: LContainer, hostTNode: TElementNode | TContainerNode | TElementContainerNode, + hostView: LViewData): ViewEngine_ViewContainerRef }; /** @@ -172,7 +172,7 @@ export function createContainerRef( private _viewRefs: viewEngine_ViewRef[] = []; constructor( - private _lContainer: LContainer, private _tContainerNode: TContainerNode, + private _lContainer: LContainer, private _hostTNode: TElementNode|TContainerNode|TElementContainerNode, private _hostView: LViewData) { super(); @@ -210,7 +210,7 @@ export function createContainerRef( const adjustedIdx = this._adjustIndex(index); const viewRef = (templateRef as any) .createEmbeddedView( - context || {}, this._lContainer, this._tContainerNode, + context || {}, this._lContainer, this._hostTNode, this._hostView, adjustedIdx); (viewRef as ViewRef).attachToViewContainerRef(this); this._viewRefs.splice(adjustedIdx, 0, viewRef); @@ -239,9 +239,7 @@ export function createContainerRef( const lView = (viewRef as ViewRef)._view !; const adjustedIdx = this._adjustIndex(index); - insertView( - lView, this._lContainer, this._hostView, adjustedIdx, - this._tContainerNode.parent !.index); + insertView(lView, this._lContainer, this._hostView, adjustedIdx, this._hostTNode.index); const container = this._getHostNode().dynamicLContainerNode !; const beforeNode = getBeforeNodeForView(adjustedIdx, this._lContainer[VIEWS], container); @@ -264,13 +262,13 @@ export function createContainerRef( remove(index?: number): void { const adjustedIdx = this._adjustIndex(index, -1); - removeView(this._lContainer, this._tContainerNode as TContainerNode, adjustedIdx); + removeView(this._lContainer, this._hostTNode, adjustedIdx); this._viewRefs.splice(adjustedIdx, 1); } detach(index?: number): viewEngine_ViewRef|null { const adjustedIdx = this._adjustIndex(index, -1); - detachView(this._lContainer, adjustedIdx, !!this._tContainerNode.detached); + detachView(this._lContainer, adjustedIdx, !!this._hostTNode.detached); return this._viewRefs.splice(adjustedIdx, 1)[0] || null; } @@ -302,17 +300,10 @@ export function createContainerRef( lContainer[RENDER_PARENT] = getRenderParent(hostTNode, hostView); appendChild(comment, hostTNode, hostView); - - if (!hostTNode.dynamicContainerNode) { - hostTNode.dynamicContainerNode = - createTNode(TNodeType.Container, -1, null, null, hostTNode, null); - } - hostLNode.dynamicLContainerNode = lContainerNode; addToViewTree(hostView, hostTNode.index as number, lContainer); - return new R3ViewContainerRef( - lContainer, hostTNode.dynamicContainerNode as TContainerNode, hostTNode, hostView); + return new R3ViewContainerRef(lContainer, hostTNode, hostView); }