* Locates the directive within the given LView and returns the matching index
(lView: LView, directiveInstance: {})
| 289 | * Locates the directive within the given LView and returns the matching index |
| 290 | */ |
| 291 | function findViaDirective(lView: LView, directiveInstance: {}): number { |
| 292 | // if a directive is monkey patched then it will (by default) |
| 293 | // have a reference to the LView of the current view. The |
| 294 | // element bound to the directive being search lives somewhere |
| 295 | // in the view data. We loop through the nodes and check their |
| 296 | // list of directives for the instance. |
| 297 | let tNode = lView[TVIEW].firstChild; |
| 298 | while (tNode) { |
| 299 | const directiveIndexStart = tNode.directiveStart; |
| 300 | const directiveIndexEnd = tNode.directiveEnd; |
| 301 | for (let i = directiveIndexStart; i < directiveIndexEnd; i++) { |
| 302 | if (lView[i] === directiveInstance) { |
| 303 | return tNode.index; |
| 304 | } |
| 305 | } |
| 306 | tNode = traverseNextElement(tNode); |
| 307 | } |
| 308 | return -1; |
| 309 | } |
| 310 | |
| 311 | /** |
| 312 | * Returns a list of directives applied to a node at a specific index. The list includes |
no test coverage detected
searching dependent graphs…