(lContainer: LContainer, removeIndex: number)
| 147 | * @returns Detached LView instance. |
| 148 | */ |
| 149 | export function detachView(lContainer: LContainer, removeIndex: number): LView | undefined { |
| 150 | if (lContainer.length <= CONTAINER_HEADER_OFFSET) return; |
| 151 | |
| 152 | const indexInContainer = CONTAINER_HEADER_OFFSET + removeIndex; |
| 153 | const viewToDetach = lContainer[indexInContainer]; |
| 154 | |
| 155 | if (viewToDetach) { |
| 156 | const declarationLContainer = viewToDetach[DECLARATION_LCONTAINER]; |
| 157 | if (declarationLContainer !== null && declarationLContainer !== lContainer) { |
| 158 | detachMovedView(declarationLContainer, viewToDetach); |
| 159 | } |
| 160 | |
| 161 | if (removeIndex > 0) { |
| 162 | lContainer[indexInContainer - 1][NEXT] = viewToDetach[NEXT] as LView; |
| 163 | } |
| 164 | const removedLView = removeFromArray(lContainer, CONTAINER_HEADER_OFFSET + removeIndex); |
| 165 | removeViewFromDOM(viewToDetach[TVIEW], viewToDetach); |
| 166 | |
| 167 | // notify query that a view has been removed |
| 168 | const lQueries = removedLView[QUERIES]; |
| 169 | if (lQueries !== null) { |
| 170 | lQueries.detachView(removedLView[TVIEW]); |
| 171 | } |
| 172 | |
| 173 | viewToDetach[PARENT] = null; |
| 174 | viewToDetach[NEXT] = null; |
| 175 | // Unsets the attached flag |
| 176 | viewToDetach[FLAGS] &= ~LViewFlags.Attached; |
| 177 | } |
| 178 | return viewToDetach; |
| 179 | } |
| 180 | |
| 181 | /** |
| 182 | * Inserts a view into a container. |
no test coverage detected
searching dependent graphs…