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

Function ingestContent

packages/compiler/src/template/pipeline/src/ingest.ts:394–442  ·  view source on GitHub ↗

* Ingest a content node from the AST into the given `ViewCompilation`.

(unit: ViewCompilationUnit, content: t.Content)

Source from the content-addressed store, hash-verified

392 * Ingest a content node from the AST into the given `ViewCompilation`.
393 */
394function ingestContent(unit: ViewCompilationUnit, content: t.Content): void {
395 if (content.i18n !== undefined && !(content.i18n instanceof i18n.TagPlaceholder)) {
396 throw Error(`Unhandled i18n metadata type for element: ${content.i18n.constructor.name}`);
397 }
398
399 let fallbackView: ViewCompilationUnit | null = null;
400
401 // Don't capture default content that's only made up of empty text nodes and comments.
402 // Note that we process the default content before the projection in order to match the
403 // insertion order at runtime.
404 if (
405 content.children.some(
406 (child) =>
407 !(child instanceof t.Comment) &&
408 (!(child instanceof t.Text) || child.value.trim().length > 0),
409 )
410 ) {
411 fallbackView = unit.job.allocateView(unit.xref);
412 ingestNodes(fallbackView, content.children);
413 }
414
415 const id = unit.job.allocateXrefId();
416 const op = ir.createProjectionOp(
417 id,
418 content.selector,
419 content.i18n,
420 fallbackView?.xref ?? null,
421 content.sourceSpan,
422 );
423 for (const attr of content.attributes) {
424 const securityContext = domSchema.securityContext(content.name, attr.name, true);
425 unit.update.push(
426 ir.createBindingOp(
427 op.xref,
428 ir.BindingKind.Attribute,
429 attr.name,
430 o.literal(attr.value),
431 null,
432 securityContext,
433 true,
434 false,
435 null,
436 asMessage(attr.i18n),
437 attr.sourceSpan,
438 ),
439 );
440 }
441 unit.create.push(op);
442}
443
444/**
445 * Ingest a literal text node from the AST into the given `ViewCompilation`.

Callers 1

ingestNodesFunction · 0.85

Calls 7

ErrorInterface · 0.85
ingestNodesFunction · 0.85
asMessageFunction · 0.85
someMethod · 0.80
allocateViewMethod · 0.80
securityContextMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected