Gets the TNode associated with an LView inside of the declaration view.
(lView: LView)
| 1052 | |
| 1053 | /** Gets the TNode associated with an LView inside of the declaration view. */ |
| 1054 | function getTNodeFromLView(lView: LView): TElementNode | TElementContainerNode | null { |
| 1055 | const tView = lView[TVIEW]; |
| 1056 | const tViewType = tView.type; |
| 1057 | |
| 1058 | // The parent pointer differs based on `TView.type`. |
| 1059 | if (tViewType === TViewType.Embedded) { |
| 1060 | ngDevMode && assertDefined(tView.declTNode, 'Embedded TNodes should have declaration parents.'); |
| 1061 | return tView.declTNode as TElementContainerNode; |
| 1062 | } else if (tViewType === TViewType.Component) { |
| 1063 | // Components don't have `TView.declTNode` because each instance of component could be |
| 1064 | // inserted in different location, hence `TView.declTNode` is meaningless. |
| 1065 | return lView[T_HOST] as TElementNode; |
| 1066 | } |
| 1067 | |
| 1068 | return null; |
| 1069 | } |
no test coverage detected