( node: ForNode, context: SSRTransformContext, disableNestedFragments = false, )
| 21 | // This is called during the 2nd transform pass to construct the SSR-specific |
| 22 | // codegen nodes. |
| 23 | export function ssrProcessFor( |
| 24 | node: ForNode, |
| 25 | context: SSRTransformContext, |
| 26 | disableNestedFragments = false, |
| 27 | ): void { |
| 28 | const needFragmentWrapper = |
| 29 | !disableNestedFragments && |
| 30 | (node.children.length !== 1 || node.children[0].type !== NodeTypes.ELEMENT) |
| 31 | const renderLoop = createFunctionExpression( |
| 32 | createForLoopParams(node.parseResult), |
| 33 | ) |
| 34 | renderLoop.body = processChildrenAsStatement( |
| 35 | node, |
| 36 | context, |
| 37 | needFragmentWrapper, |
| 38 | ) |
| 39 | // v-for always renders a fragment unless explicitly disabled |
| 40 | if (!disableNestedFragments) { |
| 41 | context.pushStringPart(`<!--[-->`) |
| 42 | } |
| 43 | context.pushStatement( |
| 44 | createCallExpression(context.helper(SSR_RENDER_LIST), [ |
| 45 | node.source, |
| 46 | renderLoop, |
| 47 | ]), |
| 48 | ) |
| 49 | if (!disableNestedFragments) { |
| 50 | context.pushStringPart(`<!--]-->`) |
| 51 | } |
| 52 | } |
no test coverage detected