* A helper function that collects (already materialized) query results from a tree of views, * starting with a provided LView.
(tView: TView, lView: LView, queryIndex: number, result: T[])
| 420 | * starting with a provided LView. |
| 421 | */ |
| 422 | function collectQueryResults<T>(tView: TView, lView: LView, queryIndex: number, result: T[]): T[] { |
| 423 | const tQuery = tView.queries!.getByIndex(queryIndex); |
| 424 | const tQueryMatches = tQuery.matches; |
| 425 | if (tQueryMatches !== null) { |
| 426 | const lViewResults = materializeViewResults<T>(tView, lView, tQuery, queryIndex); |
| 427 | |
| 428 | for (let i = 0; i < tQueryMatches.length; i += 2) { |
| 429 | const tNodeIdx = tQueryMatches[i]; |
| 430 | if (tNodeIdx > 0) { |
| 431 | result.push(lViewResults[i / 2] as T); |
| 432 | } else { |
| 433 | const childQueryIndex = tQueryMatches[i + 1]; |
| 434 | |
| 435 | const declarationLContainer = lView[-tNodeIdx] as LContainer; |
| 436 | ngDevMode && assertLContainer(declarationLContainer); |
| 437 | |
| 438 | // collect matches for views inserted in this container |
| 439 | for (let i = CONTAINER_HEADER_OFFSET; i < declarationLContainer.length; i++) { |
| 440 | const embeddedLView = declarationLContainer[i]; |
| 441 | if (embeddedLView[DECLARATION_LCONTAINER] === embeddedLView[PARENT]) { |
| 442 | collectQueryResults(embeddedLView[TVIEW], embeddedLView, childQueryIndex, result); |
| 443 | } |
| 444 | } |
| 445 | |
| 446 | // collect matches for views created from this declaration container and inserted into |
| 447 | // different containers |
| 448 | if (declarationLContainer[MOVED_VIEWS] !== null) { |
| 449 | const embeddedLViews = declarationLContainer[MOVED_VIEWS]!; |
| 450 | for (let i = 0; i < embeddedLViews.length; i++) { |
| 451 | const embeddedLView = embeddedLViews[i]; |
| 452 | collectQueryResults(embeddedLView[TVIEW], embeddedLView, childQueryIndex, result); |
| 453 | } |
| 454 | } |
| 455 | } |
| 456 | } |
| 457 | } |
| 458 | return result; |
| 459 | } |
| 460 | |
| 461 | export function loadQueryInternal<T>(lView: LView, queryIndex: number): QueryList<T> { |
| 462 | ngDevMode && |
no test coverage detected
searching dependent graphs…