Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 | 30x 30x 30x 30x 30x 16x 16x 16x 16x 11x 16x 16x 11x | import { createStructuralDirectiveTransform, ForNode, processFor, createCallExpression, createFunctionExpression, createForLoopParams, NodeTypes } from '@vue/compiler-dom' import { SSRTransformContext, processChildrenAsStatement } from '../ssrCodegenTransform' import { SSR_RENDER_LIST } from '../runtimeHelpers' // Plugin for the first transform pass, which simply constructs the AST node export const ssrTransformFor = createStructuralDirectiveTransform( 'for', processFor ) // This is called during the 2nd transform pass to construct the SSR-specific // codegen nodes. export function ssrProcessFor( node: ForNode, context: SSRTransformContext, disableNestedFragments = false ) { const needFragmentWrapper = !disableNestedFragments && (node.children.length !== 1 || node.children[0].type !== NodeTypes.ELEMENT) const renderLoop = createFunctionExpression( createForLoopParams(node.parseResult) ) renderLoop.body = processChildrenAsStatement( node.children, context, needFragmentWrapper ) // v-for always renders a fragment unless explicitly disabled if (!disableNestedFragments) { context.pushStringPart(`<!--[-->`) } context.pushStatement( createCallExpression(context.helper(SSR_RENDER_LIST), [ node.source, renderLoop ]) ) if (!disableNestedFragments) { context.pushStringPart(`<!--]-->`) } } |