import { createStructuralDirectiveTransform , ForNode , processFor , createCallExpression , createFunctionExpression , createForLoopParams , NodeTypes } from '@vue/compiler-dom' ; import { SSRTransformContext , processChildrenAsStatement } from '../ssrCodegenTransform' ; import { SSR_RENDER_LIST } from '../runtimeHelpers' ; export const ssrTransformFor = createStructuralDirectiveTransform ( 'for' , processFor ) ; export function ssrProcessFor ( node , context , 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 ) ; if ( ! disableNestedFragments ) { context . pushStringPart ( `<!--[-->` ) ; } context . pushStatement ( createCallExpression ( context . helper ( SSR_RENDER_LIST ) , [ node . source , renderLoop ] ) ) ; if ( ! disableNestedFragments ) { context . pushStringPart ( `<!--]-->` ) ; } }