MCPcopy
hub / github.com/vuejs/core / ssrProcessFor

Function ssrProcessFor

packages/compiler-ssr/src/transforms/ssrVFor.ts:23–52  ·  view source on GitHub ↗
(
  node: ForNode,
  context: SSRTransformContext,
  disableNestedFragments = false,
)

Source from the content-addressed store, hash-verified

21// This is called during the 2nd transform pass to construct the SSR-specific
22// codegen nodes.
23export 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}

Callers 1

processChildrenFunction · 0.90

Calls 7

createFunctionExpressionFunction · 0.85
createForLoopParamsFunction · 0.85
createCallExpressionFunction · 0.85
pushStringPartMethod · 0.80
pushStatementMethod · 0.80
helperMethod · 0.65

Tested by

no test coverage detected