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

Function applyProjectionRecursive

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

* `applyProjectionRecursive` performs operation on the projection specified by `action` (insert, * detach, destroy) * * Inserting a projection requires us to locate the projected nodes from the parent component. The * complication is that those nodes themselves could be re-projected from their p

(
  renderer: Renderer,
  action: WalkTNodeTreeAction,
  lView: LView,
  tProjectionNode: TProjectionNode,
  parentRElement: RElement | null,
  beforeNode: RNode | null,
)

Source from the content-addressed store, hash-verified

1016 * @param beforeNode Before which node the insertions should happen.
1017 */
1018function applyProjectionRecursive(
1019 renderer: Renderer,
1020 action: WalkTNodeTreeAction,
1021 lView: LView,
1022 tProjectionNode: TProjectionNode,
1023 parentRElement: RElement | null,
1024 beforeNode: RNode | null,
1025) {
1026 const componentLView = lView[DECLARATION_COMPONENT_VIEW];
1027 const componentNode = componentLView[T_HOST] as TElementNode;
1028 ngDevMode &&
1029 assertEqual(typeof tProjectionNode.projection, 'number', 'expecting projection index');
1030 const nodeToProjectOrRNodes = componentNode.projection![tProjectionNode.projection]!;
1031 if (Array.isArray(nodeToProjectOrRNodes)) {
1032 // This should not exist, it is a bit of a hack. When we bootstrap a top level node and we
1033 // need to support passing projectable nodes, so we cheat and put them in the TNode
1034 // of the Host TView. (Yes we put instance info at the T Level). We can get away with it
1035 // because we know that TView is not shared and therefore it will not be a problem.
1036 // This should be refactored and cleaned up.
1037 for (let i = 0; i < nodeToProjectOrRNodes.length; i++) {
1038 const rNode = nodeToProjectOrRNodes[i];
1039 applyToElementOrContainer(
1040 action,
1041 renderer,
1042 lView[INJECTOR],
1043 parentRElement,
1044 rNode,
1045 tProjectionNode,
1046 beforeNode,
1047 lView,
1048 );
1049 }
1050 } else {
1051 let nodeToProject: TNode | null = nodeToProjectOrRNodes;
1052 const projectedComponentLView = componentLView[PARENT] as LView;
1053 // If a parent <ng-content> is located within a skip hydration block,
1054 // annotate an actual node that is being projected with the same flag too.
1055 if (hasInSkipHydrationBlockFlag(tProjectionNode)) {
1056 nodeToProject.flags |= TNodeFlags.inSkipHydrationBlock;
1057 }
1058 applyNodes(
1059 renderer,
1060 action,
1061 nodeToProject,
1062 projectedComponentLView,
1063 parentRElement,
1064 beforeNode,
1065 true,
1066 );
1067 }
1068}
1069
1070/**
1071 * `applyContainer` performs an operation on the container and its views as specified by

Callers 2

applyNodesFunction · 0.85
applyProjectionFunction · 0.85

Calls 5

assertEqualFunction · 0.90
applyNodesFunction · 0.85
isArrayMethod · 0.80

Tested by

no test coverage detected