( parent: Container, context: SSRTransformContext, asFragment = false, disableNestedFragments = false, disableComment = false, )
| 152 | } |
| 153 | |
| 154 | export function processChildren( |
| 155 | parent: Container, |
| 156 | context: SSRTransformContext, |
| 157 | asFragment = false, |
| 158 | disableNestedFragments = false, |
| 159 | disableComment = false, |
| 160 | ): void { |
| 161 | if (asFragment) { |
| 162 | context.pushStringPart(`<!--[-->`) |
| 163 | } |
| 164 | const { children } = parent |
| 165 | for (let i = 0; i < children.length; i++) { |
| 166 | const child = children[i] |
| 167 | switch (child.type) { |
| 168 | case NodeTypes.ELEMENT: |
| 169 | switch (child.tagType) { |
| 170 | case ElementTypes.ELEMENT: |
| 171 | ssrProcessElement(child, context) |
| 172 | break |
| 173 | case ElementTypes.COMPONENT: |
| 174 | ssrProcessComponent(child, context, parent) |
| 175 | break |
| 176 | case ElementTypes.SLOT: |
| 177 | ssrProcessSlotOutlet(child, context) |
| 178 | break |
| 179 | case ElementTypes.TEMPLATE: |
| 180 | // TODO |
| 181 | break |
| 182 | default: |
| 183 | context.onError( |
| 184 | createSSRCompilerError( |
| 185 | SSRErrorCodes.X_SSR_INVALID_AST_NODE, |
| 186 | (child as any).loc, |
| 187 | ), |
| 188 | ) |
| 189 | // make sure we exhaust all possible types |
| 190 | const exhaustiveCheck: never = child |
| 191 | return exhaustiveCheck |
| 192 | } |
| 193 | break |
| 194 | case NodeTypes.TEXT: |
| 195 | context.pushStringPart(escapeHtml(child.content)) |
| 196 | break |
| 197 | case NodeTypes.COMMENT: |
| 198 | // no need to escape comment here because the AST can only |
| 199 | // contain valid comments. |
| 200 | if (!disableComment) { |
| 201 | context.pushStringPart(`<!--${child.content}-->`) |
| 202 | } |
| 203 | break |
| 204 | case NodeTypes.INTERPOLATION: |
| 205 | context.pushStringPart( |
| 206 | createCallExpression(context.helper(SSR_INTERPOLATE), [ |
| 207 | child.content, |
| 208 | ]), |
| 209 | ) |
| 210 | break |
| 211 | case NodeTypes.IF: |
no test coverage detected