MCPcopy Create free account
hub / github.com/angular/angular / applyContainer

Function applyContainer

packages/core/src/render3/node_manipulation.ts:1083–1123  ·  view source on GitHub ↗

* `applyContainer` performs an operation on the container and its views as specified by * `action` (insert, detach, destroy) * * Inserting a Container is complicated by the fact that the container may have Views which * themselves have containers or projections. * * @param renderer Renderer to

(
  renderer: Renderer,
  action: WalkTNodeTreeAction,
  injector: Injector,
  lContainer: LContainer,
  tNode: TNode,
  parentRElement: RElement | null,
  beforeNode: RNode | null | undefined,
)

Source from the content-addressed store, hash-verified

1081 * @param beforeNode Before which node the insertions should happen.
1082 */
1083function applyContainer(
1084 renderer: Renderer,
1085 action: WalkTNodeTreeAction,
1086 injector: Injector,
1087 lContainer: LContainer,
1088 tNode: TNode,
1089 parentRElement: RElement | null,
1090 beforeNode: RNode | null | undefined,
1091) {
1092 ngDevMode && assertLContainer(lContainer);
1093 const anchor = lContainer[NATIVE]; // LContainer has its own before node.
1094 const native = unwrapRNode(lContainer);
1095 // An LContainer can be created dynamically on any node by injecting ViewContainerRef.
1096 // Asking for a ViewContainerRef on an element will result in a creation of a separate anchor
1097 // node (comment in the DOM) that will be different from the LContainer's host node. In this
1098 // particular case we need to execute action on 2 nodes:
1099 // - container's host node (this is done in the executeActionOnElementOrContainer)
1100 // - container's host node (this is done here)
1101 if (anchor !== native) {
1102 // This is very strange to me (Misko). I would expect that the native is same as anchor. I
1103 // don't see a reason why they should be different, but they are.
1104 //
1105 // If they are we need to process the second anchor as well.
1106 applyToElementOrContainer(
1107 action,
1108 renderer,
1109 injector,
1110 parentRElement,
1111 anchor,
1112 tNode,
1113 beforeNode,
1114 );
1115 }
1116 if ((lContainer[FLAGS] & LContainerFlags.LogicalOnly) !== 0) {
1117 return;
1118 }
1119 for (let i = CONTAINER_HEADER_OFFSET; i < lContainer.length; i++) {
1120 const lView = lContainer[i] as LView;
1121 applyView(lView[TVIEW], lView, renderer, action, parentRElement, anchor);
1122 }
1123}
1124
1125/**
1126 * Writes class/style to element.

Callers 1

Calls 4

assertLContainerFunction · 0.90
unwrapRNodeFunction · 0.90
applyViewFunction · 0.85

Tested by

no test coverage detected