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

Function applyContainer

packages/core/src/render3/node_manipulation.ts:1058–1098  ·  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

1056 * @param beforeNode Before which node the insertions should happen.
1057 */
1058function applyContainer(
1059 renderer: Renderer,
1060 action: WalkTNodeTreeAction,
1061 injector: Injector,
1062 lContainer: LContainer,
1063 tNode: TNode,
1064 parentRElement: RElement | null,
1065 beforeNode: RNode | null | undefined,
1066) {
1067 ngDevMode && assertLContainer(lContainer);
1068 const anchor = lContainer[NATIVE]; // LContainer has its own before node.
1069 const native = unwrapRNode(lContainer);
1070 // An LContainer can be created dynamically on any node by injecting ViewContainerRef.
1071 // Asking for a ViewContainerRef on an element will result in a creation of a separate anchor
1072 // node (comment in the DOM) that will be different from the LContainer's host node. In this
1073 // particular case we need to execute action on 2 nodes:
1074 // - container's host node (this is done in the executeActionOnElementOrContainer)
1075 // - container's host node (this is done here)
1076 if (anchor !== native) {
1077 // This is very strange to me (Misko). I would expect that the native is same as anchor. I
1078 // don't see a reason why they should be different, but they are.
1079 //
1080 // If they are we need to process the second anchor as well.
1081 applyToElementOrContainer(
1082 action,
1083 renderer,
1084 injector,
1085 parentRElement,
1086 anchor,
1087 tNode,
1088 beforeNode,
1089 );
1090 }
1091 if ((lContainer[FLAGS] & LContainerFlags.LogicalOnly) !== 0) {
1092 return;
1093 }
1094 for (let i = CONTAINER_HEADER_OFFSET; i < lContainer.length; i++) {
1095 const lView = lContainer[i] as LView;
1096 applyView(lView[TVIEW], lView, renderer, action, parentRElement, anchor);
1097 }
1098}
1099
1100/**
1101 * Writes class/style to element.

Callers 1

Calls 4

assertLContainerFunction · 0.90
unwrapRNodeFunction · 0.90
applyViewFunction · 0.85

Tested by

no test coverage detected