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