(elementOrDir: Element | {})
| 103 | * @publicApi |
| 104 | */ |
| 105 | export function getOwningComponent<T>(elementOrDir: Element | {}): T | null { |
| 106 | const context = getLContext(elementOrDir)!; |
| 107 | let lView = context ? context.lView : null; |
| 108 | if (lView === null) return null; |
| 109 | |
| 110 | let parent: LView | null; |
| 111 | while (lView[TVIEW].type === TViewType.Embedded && (parent = getLViewParent(lView)!)) { |
| 112 | lView = parent; |
| 113 | } |
| 114 | return isRootView(lView) ? null : (lView[CONTEXT] as unknown as T); |
| 115 | } |
| 116 | |
| 117 | /** |
| 118 | * Retrieves all root components associated with a DOM element, directive or component instance. |
no test coverage detected
searching dependent graphs…