(node: Node)
| 200 | * @publicApi |
| 201 | */ |
| 202 | export function getDirectives(node: Node): {}[] { |
| 203 | // Skip text nodes because we can't have directives associated with them. |
| 204 | if (node instanceof Text) { |
| 205 | return []; |
| 206 | } |
| 207 | |
| 208 | const context = getLContext(node)!; |
| 209 | const lView = context ? context.lView : null; |
| 210 | if (lView === null) { |
| 211 | return []; |
| 212 | } |
| 213 | |
| 214 | const tView = lView[TVIEW]; |
| 215 | const nodeIndex = context.nodeIndex; |
| 216 | if (!tView?.data[nodeIndex]) { |
| 217 | return []; |
| 218 | } |
| 219 | if (context.directives === undefined) { |
| 220 | context.directives = getDirectivesAtNodeIndex(nodeIndex, lView); |
| 221 | } |
| 222 | |
| 223 | // The `directives` in this case are a named array called `LComponentView`. Clone the |
| 224 | // result so we don't expose an internal data structure in the user's console. |
| 225 | return context.directives === null ? [] : [...context.directives]; |
| 226 | } |
| 227 | |
| 228 | /** Metadata common to directives from all frameworks. */ |
| 229 | export interface BaseDirectiveDebugMetadata { |
no test coverage detected
searching dependent graphs…