wip(ssr): v-for
This commit is contained in:
@@ -1,9 +1,18 @@
|
||||
import {
|
||||
createStructuralDirectiveTransform,
|
||||
ForNode,
|
||||
processForNode
|
||||
processForNode,
|
||||
createCallExpression,
|
||||
createFunctionExpression,
|
||||
createForLoopParams,
|
||||
createBlockStatement
|
||||
} from '@vue/compiler-dom'
|
||||
import { SSRTransformContext } from '../ssrCodegenTransform'
|
||||
import {
|
||||
SSRTransformContext,
|
||||
createChildContext,
|
||||
processChildren
|
||||
} from '../ssrCodegenTransform'
|
||||
import { SSR_RENDER_LIST } from '../runtimeHelpers'
|
||||
|
||||
// Plugin for the first transform pass, which simply constructs the AST node
|
||||
export const ssrTransformFor = createStructuralDirectiveTransform(
|
||||
@@ -13,4 +22,17 @@ export const ssrTransformFor = createStructuralDirectiveTransform(
|
||||
|
||||
// This is called during the 2nd transform pass to construct the SSR-sepcific
|
||||
// codegen nodes.
|
||||
export function processFor(node: ForNode, context: SSRTransformContext) {}
|
||||
export function processFor(node: ForNode, context: SSRTransformContext) {
|
||||
const renderLoop = createFunctionExpression(
|
||||
createForLoopParams(node.parseResult)
|
||||
)
|
||||
const childContext = createChildContext(context)
|
||||
processChildren(node.children, childContext)
|
||||
renderLoop.body = createBlockStatement(childContext.body)
|
||||
context.pushStatement(
|
||||
createCallExpression(context.helper(SSR_RENDER_LIST), [
|
||||
node.source,
|
||||
renderLoop
|
||||
])
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user