* `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, )
| 1080 | * @param beforeNode Before which node the insertions should happen. |
| 1081 | */ |
| 1082 | function applyContainer( |
| 1083 | renderer: Renderer, |
| 1084 | action: WalkTNodeTreeAction, |
| 1085 | injector: Injector, |
| 1086 | lContainer: LContainer, |
| 1087 | tNode: TNode, |
| 1088 | parentRElement: RElement | null, |
| 1089 | beforeNode: RNode | null | undefined, |
| 1090 | ) { |
| 1091 | ngDevMode && assertLContainer(lContainer); |
| 1092 | const anchor = lContainer[NATIVE]; // LContainer has its own before node. |
| 1093 | const native = unwrapRNode(lContainer); |
| 1094 | // An LContainer can be created dynamically on any node by injecting ViewContainerRef. |
| 1095 | // Asking for a ViewContainerRef on an element will result in a creation of a separate anchor |
| 1096 | // node (comment in the DOM) that will be different from the LContainer's host node. In this |
| 1097 | // particular case we need to execute action on 2 nodes: |
| 1098 | // - container's host node (this is done in the executeActionOnElementOrContainer) |
| 1099 | // - container's host node (this is done here) |
| 1100 | if (anchor !== native) { |
| 1101 | // This is very strange to me (Misko). I would expect that the native is same as anchor. I |
| 1102 | // don't see a reason why they should be different, but they are. |
| 1103 | // |
| 1104 | // If they are we need to process the second anchor as well. |
| 1105 | applyToElementOrContainer( |
| 1106 | action, |
| 1107 | renderer, |
| 1108 | injector, |
| 1109 | parentRElement, |
| 1110 | anchor, |
| 1111 | tNode, |
| 1112 | beforeNode, |
| 1113 | ); |
| 1114 | } |
| 1115 | if ((lContainer[FLAGS] & LContainerFlags.LogicalOnly) !== 0) { |
| 1116 | return; |
| 1117 | } |
| 1118 | for (let i = CONTAINER_HEADER_OFFSET; i < lContainer.length; i++) { |
| 1119 | const lView = lContainer[i] as LView; |
| 1120 | applyView(lView[TVIEW], lView, renderer, action, parentRElement, anchor); |
| 1121 | } |
| 1122 | } |
| 1123 | |
| 1124 | /** |
| 1125 | * Writes class/style to element. |
no test coverage detected