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

Function applyProjectionRecursive

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

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