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

Function createDeferredBlock

packages/compiler/src/render3/r3_deferred_blocks.ts:58–104  ·  view source on GitHub ↗
(
  ast: html.Block,
  connectedBlocks: html.Block[],
  visitor: html.Visitor,
  bindingParser: BindingParser,
)

Source from the content-addressed store, hash-verified

56
57/** Creates a deferred block from an HTML AST node. */
58export function createDeferredBlock(
59 ast: html.Block,
60 connectedBlocks: html.Block[],
61 visitor: html.Visitor,
62 bindingParser: BindingParser,
63): {node: t.DeferredBlock; errors: ParseError[]} {
64 const errors: ParseError[] = [];
65 const {placeholder, loading, error} = parseConnectedBlocks(connectedBlocks, errors, visitor);
66 const {triggers, prefetchTriggers, hydrateTriggers} = parsePrimaryTriggers(
67 ast,
68 bindingParser,
69 errors,
70 placeholder,
71 );
72
73 // The `defer` block has a main span encompassing all of the connected branches as well.
74 let lastEndSourceSpan = ast.endSourceSpan;
75 let endOfLastSourceSpan = ast.sourceSpan.end;
76 if (connectedBlocks.length > 0) {
77 const lastConnectedBlock = connectedBlocks[connectedBlocks.length - 1];
78 lastEndSourceSpan = lastConnectedBlock.endSourceSpan;
79 endOfLastSourceSpan = lastConnectedBlock.sourceSpan.end;
80 }
81
82 const sourceSpanWithConnectedBlocks = new ParseSourceSpan(
83 ast.sourceSpan.start,
84 endOfLastSourceSpan,
85 );
86
87 const node = new t.DeferredBlock(
88 html.visitAll(visitor, ast.children, ast.children),
89 triggers,
90 prefetchTriggers,
91 hydrateTriggers,
92 placeholder,
93 loading,
94 error,
95 ast.nameSpan,
96 sourceSpanWithConnectedBlocks,
97 ast.sourceSpan,
98 ast.startSourceSpan,
99 lastEndSourceSpan,
100 ast.i18n,
101 );
102
103 return {node, errors};
104}
105
106function parseConnectedBlocks(
107 connectedBlocks: html.Block[],

Callers 1

visitBlockMethod · 0.90

Calls 3

parseConnectedBlocksFunction · 0.85
parsePrimaryTriggersFunction · 0.85
visitAllMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…