MCPcopy Create free account
hub / github.com/angular/angular / ɵɵprojectionDef

Function ɵɵprojectionDef

packages/core/src/render3/instructions/projection.ts:96–131  ·  view source on GitHub ↗
(projectionSlots?: (string | (string | number)[][])[])

Source from the content-addressed store, hash-verified

94 * @codeGenApi
95 */
96export function ɵɵprojectionDef(projectionSlots?: (string | (string | number)[][])[]): void {
97 const componentNode = getLView()[DECLARATION_COMPONENT_VIEW][T_HOST] as TElementNode;
98
99 if (!componentNode.projection) {
100 // If no explicit projection slots are defined, fall back to a single
101 // projection slot with the wildcard selector.
102 const numProjectionSlots = projectionSlots ? projectionSlots.length : 1;
103 const projectionHeads: (TNode | null)[] = (componentNode.projection = newArray(
104 numProjectionSlots,
105 null! as TNode,
106 ));
107 const tails: (TNode | null)[] = projectionHeads.slice();
108
109 let componentChild: TNode | null = componentNode.child;
110
111 while (componentChild !== null) {
112 // Do not project let declarations so they don't occupy a slot.
113 if (componentChild.type !== TNodeType.LetDeclaration) {
114 const slotIndex = projectionSlots
115 ? matchingProjectionSlotIndex(componentChild, projectionSlots as ProjectionSlots)
116 : 0;
117
118 if (slotIndex !== null) {
119 if (tails[slotIndex]) {
120 tails[slotIndex]!.projectionNext = componentChild;
121 } else {
122 projectionHeads[slotIndex] = componentChild;
123 }
124 tails[slotIndex] = componentChild;
125 }
126 }
127
128 componentChild = componentChild.next;
129 }
130 }
131}
132
133/**
134 * Inserts previously re-distributed projected nodes. This instruction must be preceded by a call

Callers

nothing calls this directly

Calls 3

getLViewFunction · 0.90
newArrayFunction · 0.90

Tested by

no test coverage detected