* `applyContainer` performs an operation on the container and its views as specified by * `action` (insert, detach, destroy) * * Inserting a Container is complicated by the fact that the container may have Views which * themselves have containers or projections. * * @param renderer Renderer to
( renderer: Renderer, action: WalkTNodeTreeAction, injector: Injector, lContainer: LContainer, tNode: TNode, parentRElement: RElement | null, beforeNode: RNode | null | undefined, )
| 1003 | * @param beforeNode Before which node the insertions should happen. |
| 1004 | */ |
| 1005 | function applyContainer( |
| 1006 | renderer: Renderer, |
| 1007 | action: WalkTNodeTreeAction, |
| 1008 | injector: Injector, |
| 1009 | lContainer: LContainer, |
| 1010 | tNode: TNode, |
| 1011 | parentRElement: RElement | null, |
| 1012 | beforeNode: RNode | null | undefined, |
| 1013 | ) { |
| 1014 | ngDevMode && assertLContainer(lContainer); |
| 1015 | const anchor = lContainer[NATIVE]; // LContainer has its own before node. |
| 1016 | const native = unwrapRNode(lContainer); |
| 1017 | // An LContainer can be created dynamically on any node by injecting ViewContainerRef. |
| 1018 | // Asking for a ViewContainerRef on an element will result in a creation of a separate anchor |
| 1019 | // node (comment in the DOM) that will be different from the LContainer's host node. In this |
| 1020 | // particular case we need to execute action on 2 nodes: |
| 1021 | // - container's host node (this is done in the executeActionOnElementOrContainer) |
| 1022 | // - container's host node (this is done here) |
| 1023 | if (anchor !== native) { |
| 1024 | // This is very strange to me (Misko). I would expect that the native is same as anchor. I |
| 1025 | // don't see a reason why they should be different, but they are. |
| 1026 | // |
| 1027 | // If they are we need to process the second anchor as well. |
| 1028 | applyToElementOrContainer( |
| 1029 | action, |
| 1030 | renderer, |
| 1031 | injector, |
| 1032 | parentRElement, |
| 1033 | anchor, |
| 1034 | tNode, |
| 1035 | beforeNode, |
| 1036 | ); |
| 1037 | } |
| 1038 | for (let i = CONTAINER_HEADER_OFFSET; i < lContainer.length; i++) { |
| 1039 | const lView = lContainer[i] as LView; |
| 1040 | applyView(lView[TVIEW], lView, renderer, action, parentRElement, anchor); |
| 1041 | } |
| 1042 | } |
| 1043 | |
| 1044 | /** |
| 1045 | * Writes class/style to element. |
no test coverage detected
searching dependent graphs…