perf: hoist dynamic props lists
This commit is contained in:
@@ -288,7 +288,7 @@ export interface VNodeCall extends Node {
|
||||
| ForRenderListExpression // v-for fragment call
|
||||
| undefined
|
||||
patchFlag: string | undefined
|
||||
dynamicProps: string | undefined
|
||||
dynamicProps: string | SimpleExpressionNode | undefined
|
||||
directives: DirectiveArguments | undefined
|
||||
isBlock: boolean
|
||||
disableTracking: boolean
|
||||
|
||||
@@ -113,7 +113,7 @@ export interface TransformContext
|
||||
onNodeRemoved(): void
|
||||
addIdentifiers(exp: ExpressionNode | string): void
|
||||
removeIdentifiers(exp: ExpressionNode | string): void
|
||||
hoist(exp: JSChildNode): SimpleExpressionNode
|
||||
hoist(exp: string | JSChildNode): SimpleExpressionNode
|
||||
cache<T extends JSChildNode>(exp: T, isVNode?: boolean): CacheExpression | T
|
||||
constantCache: Map<TemplateChildNode, ConstantTypes>
|
||||
|
||||
@@ -277,6 +277,7 @@ export function createTransformContext(
|
||||
}
|
||||
},
|
||||
hoist(exp) {
|
||||
if (isString(exp)) exp = createSimpleExpression(exp, false)
|
||||
context.hoists.push(exp)
|
||||
const identifier = createSimpleExpression(
|
||||
`_hoisted_${context.hoists.length}`,
|
||||
|
||||
@@ -102,6 +102,9 @@ function walk(
|
||||
codegenNode.props = context.hoist(props)
|
||||
}
|
||||
}
|
||||
if (codegenNode.dynamicProps) {
|
||||
codegenNode.dynamicProps = context.hoist(codegenNode.dynamicProps)
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (child.type === NodeTypes.TEXT_CALL) {
|
||||
|
||||
Reference in New Issue
Block a user