MCPcopy Index your code
hub / github.com/angular/angular / parseConnectedBlocks

Function parseConnectedBlocks

packages/compiler/src/render3/r3_deferred_blocks.ts:106–165  ·  view source on GitHub ↗
(
  connectedBlocks: html.Block[],
  errors: ParseError[],
  visitor: html.Visitor,
)

Source from the content-addressed store, hash-verified

104}
105
106function parseConnectedBlocks(
107 connectedBlocks: html.Block[],
108 errors: ParseError[],
109 visitor: html.Visitor,
110) {
111 let placeholder: t.DeferredBlockPlaceholder | null = null;
112 let loading: t.DeferredBlockLoading | null = null;
113 let error: t.DeferredBlockError | null = null;
114
115 for (const block of connectedBlocks) {
116 try {
117 if (!isConnectedDeferLoopBlock(block.name)) {
118 errors.push(new ParseError(block.startSourceSpan, `Unrecognized block "@${block.name}"`));
119 break;
120 }
121
122 switch (block.name) {
123 case 'placeholder':
124 if (placeholder !== null) {
125 errors.push(
126 new ParseError(
127 block.startSourceSpan,
128 `@defer block can only have one @placeholder block`,
129 ),
130 );
131 } else {
132 placeholder = parsePlaceholderBlock(block, visitor);
133 }
134 break;
135
136 case 'loading':
137 if (loading !== null) {
138 errors.push(
139 new ParseError(
140 block.startSourceSpan,
141 `@defer block can only have one @loading block`,
142 ),
143 );
144 } else {
145 loading = parseLoadingBlock(block, visitor);
146 }
147 break;
148
149 case 'error':
150 if (error !== null) {
151 errors.push(
152 new ParseError(block.startSourceSpan, `@defer block can only have one @error block`),
153 );
154 } else {
155 error = parseErrorBlock(block, visitor);
156 }
157 break;
158 }
159 } catch (e) {
160 errors.push(new ParseError(block.startSourceSpan, (e as Error).message));
161 }
162 }
163

Callers 1

createDeferredBlockFunction · 0.85

Calls 5

parsePlaceholderBlockFunction · 0.85
parseLoadingBlockFunction · 0.85
parseErrorBlockFunction · 0.85
pushMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…