* Locates the directive within the given LView and returns the matching index
(lView: LView, directiveInstance: {})
| 273 | * Locates the directive within the given LView and returns the matching index |
| 274 | */ |
| 275 | function findViaDirective(lView: LView, directiveInstance: {}): number { |
| 276 | // if a directive is monkey patched then it will (by default) |
| 277 | // have a reference to the LView of the current view. The |
| 278 | // element bound to the directive being search lives somewhere |
| 279 | // in the view data. We loop through the nodes and check their |
| 280 | // list of directives for the instance. |
| 281 | let tNode = lView[TVIEW].firstChild; |
| 282 | while (tNode) { |
| 283 | const directiveIndexStart = tNode.directiveStart; |
| 284 | const directiveIndexEnd = tNode.directiveEnd; |
| 285 | for (let i = directiveIndexStart; i < directiveIndexEnd; i++) { |
| 286 | if (lView[i] === directiveInstance) { |
| 287 | return tNode.index; |
| 288 | } |
| 289 | } |
| 290 | tNode = traverseNextElement(tNode); |
| 291 | } |
| 292 | return -1; |
| 293 | } |
| 294 | |
| 295 | /** |
| 296 | * Returns a list of directives applied to a node at a specific index. The list includes |
no test coverage detected