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

Function materializeViewResults

packages/core/src/render3/queries/query.ts:392–420  ·  view source on GitHub ↗

* A helper function that creates query results for a given view. This function is meant to do the * processing once and only once for a given view instance (a set of results for a given view * doesn't change).

(
  tView: TView,
  lView: LView,
  tQuery: TQuery,
  queryIndex: number,
)

Source from the content-addressed store, hash-verified

390 * doesn't change).
391 */
392function materializeViewResults<T>(
393 tView: TView,
394 lView: LView,
395 tQuery: TQuery,
396 queryIndex: number,
397): T[] {
398 const lQuery = lView[QUERIES]!.queries![queryIndex];
399 if (lQuery.matches === null) {
400 const tViewData = tView.data;
401 const tQueryMatches = tQuery.matches;
402 const result: Array<T | null> = [];
403 for (let i = 0; tQueryMatches !== null && i < tQueryMatches.length; i += 2) {
404 const matchedNodeIdx = tQueryMatches[i];
405 if (matchedNodeIdx < 0) {
406 // we at the <ng-template> marker which might have results in views created based on this
407 // <ng-template> - those results will be in separate views though, so here we just leave
408 // null as a placeholder
409 result.push(null);
410 } else {
411 ngDevMode && assertIndexInRange(tViewData, matchedNodeIdx);
412 const tNode = tViewData[matchedNodeIdx] as TNode;
413 result.push(createResultForNode(lView, tNode, tQueryMatches[i + 1], tQuery.metadata.read));
414 }
415 }
416 lQuery.matches = result;
417 }
418
419 return lQuery.matches;
420}
421
422/**
423 * A helper function that collects (already materialized) query results from a tree of views,

Callers 2

collectQueryResultsFunction · 0.85
getQueryResultsFunction · 0.85

Calls 3

assertIndexInRangeFunction · 0.90
createResultForNodeFunction · 0.85
pushMethod · 0.45

Tested by

no test coverage detected