(element: Element)
| 153 | * @param element Element for which the injection tokens should be retrieved. |
| 154 | */ |
| 155 | export function getInjectionTokens(element: Element): any[] { |
| 156 | const context = getLContext(element)!; |
| 157 | const lView = context ? context.lView : null; |
| 158 | if (lView === null) return []; |
| 159 | const tView = lView[TVIEW]; |
| 160 | const tNode = tView.data[context.nodeIndex] as TNode; |
| 161 | const providerTokens: any[] = []; |
| 162 | const startIndex = tNode.providerIndexes & TNodeProviderIndexes.ProvidersStartIndexMask; |
| 163 | const endIndex = tNode.directiveEnd; |
| 164 | for (let i = startIndex; i < endIndex; i++) { |
| 165 | let value = tView.data[i]; |
| 166 | if (isDirectiveDefHack(value)) { |
| 167 | // The fact that we sometimes store Type and sometimes DirectiveDef in this location is a |
| 168 | // design flaw. We should always store same type so that we can be monomorphic. The issue |
| 169 | // is that for Components/Directives we store the def instead the type. The correct behavior |
| 170 | // is that we should always be storing injectable type in this location. |
| 171 | value = value.type; |
| 172 | } |
| 173 | providerTokens.push(value); |
| 174 | } |
| 175 | return providerTokens; |
| 176 | } |
| 177 | |
| 178 | /** |
| 179 | * Retrieves directive instances associated with a given DOM node. Does not include |
no test coverage detected
searching dependent graphs…