* Locates the component within the given LView and returns the matching index
(lView: LView, componentInstance: {})
| 264 | * Locates the component within the given LView and returns the matching index |
| 265 | */ |
| 266 | function findViaComponent(lView: LView, componentInstance: {}): number { |
| 267 | const componentIndices = lView[TVIEW].components; |
| 268 | if (componentIndices) { |
| 269 | for (let i = 0; i < componentIndices.length; i++) { |
| 270 | const elementComponentIndex = componentIndices[i]; |
| 271 | const componentView = getComponentLViewByIndex(elementComponentIndex, lView); |
| 272 | if (componentView[CONTEXT] === componentInstance) { |
| 273 | return elementComponentIndex; |
| 274 | } |
| 275 | } |
| 276 | } else { |
| 277 | const rootComponentView = getComponentLViewByIndex(HEADER_OFFSET, lView); |
| 278 | const rootComponent = rootComponentView[CONTEXT]; |
| 279 | if (rootComponent === componentInstance) { |
| 280 | // we are dealing with the root element here therefore we know that the |
| 281 | // element is the very first element after the HEADER data in the lView |
| 282 | return HEADER_OFFSET; |
| 283 | } |
| 284 | } |
| 285 | return -1; |
| 286 | } |
| 287 | |
| 288 | /** |
| 289 | * Locates the directive within the given LView and returns the matching index |
no test coverage detected
searching dependent graphs…