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

Function parseWhenTrigger

packages/compiler/src/render3/r3_deferred_triggers.ts:92–125  ·  view source on GitHub ↗
(
  {expression, sourceSpan}: html.BlockParameter,
  bindingParser: BindingParser,
  triggers: t.DeferredBlockTriggers,
  errors: ParseError[],
)

Source from the content-addressed store, hash-verified

90
91/** Parses a `when` deferred trigger. */
92export function parseWhenTrigger(
93 {expression, sourceSpan}: html.BlockParameter,
94 bindingParser: BindingParser,
95 triggers: t.DeferredBlockTriggers,
96 errors: ParseError[],
97): void {
98 const whenIndex = expression.indexOf('when');
99 const whenSourceSpan = new ParseSourceSpan(
100 sourceSpan.start.moveBy(whenIndex),
101 sourceSpan.start.moveBy(whenIndex + 'when'.length),
102 );
103 const prefetchSpan = getPrefetchSpan(expression, sourceSpan);
104 const hydrateSpan = getHydrateSpan(expression, sourceSpan);
105
106 // This is here just to be safe, we shouldn't enter this function
107 // in the first place if a block doesn't have the "when" keyword.
108 if (whenIndex === -1) {
109 errors.push(new ParseError(sourceSpan, `Could not find "when" keyword in expression`));
110 } else {
111 const start = getTriggerParametersStart(expression, whenIndex + 1);
112 const parsed = bindingParser.parseBinding(
113 expression.slice(start),
114 false,
115 sourceSpan,
116 sourceSpan.start.offset + start,
117 );
118 trackTrigger(
119 'when',
120 triggers,
121 errors,
122 new t.BoundDeferredTrigger(parsed, sourceSpan, prefetchSpan, whenSourceSpan, hydrateSpan),
123 );
124 }
125}
126
127/** Parses an `on` trigger */
128export function parseOnTrigger(

Callers 1

parsePrimaryTriggersFunction · 0.90

Calls 8

getPrefetchSpanFunction · 0.85
getHydrateSpanFunction · 0.85
trackTriggerFunction · 0.85
indexOfMethod · 0.80
moveByMethod · 0.80
pushMethod · 0.45
parseBindingMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…