refactor: isVNode -> isVOnce

This commit is contained in:
Evan You 2024-07-13 21:07:45 +08:00
parent 2815531fd5
commit 3107b57e2e
No known key found for this signature in database
GPG Key ID: 00E9AB7A6704CE0A
2 changed files with 5 additions and 5 deletions

View File

@ -416,7 +416,7 @@ export interface CacheExpression extends Node {
type: NodeTypes.JS_CACHE_EXPRESSION
index: number
value: JSChildNode
isVNode: boolean
isVOnce: boolean
}
export interface MemoExpression extends CallExpression {
@ -771,13 +771,13 @@ export function createConditionalExpression(
export function createCacheExpression(
index: number,
value: JSChildNode,
isVNode: boolean = false,
isVOnce: boolean = false,
): CacheExpression {
return {
type: NodeTypes.JS_CACHE_EXPRESSION,
index,
value,
isVNode,
isVOnce,
loc: locStub,
}
}

View File

@ -1037,14 +1037,14 @@ function genConditionalExpression(
function genCacheExpression(node: CacheExpression, context: CodegenContext) {
const { push, helper, indent, deindent, newline } = context
push(`_cache[${node.index}] || (`)
if (node.isVNode) {
if (node.isVOnce) {
indent()
push(`${helper(SET_BLOCK_TRACKING)}(-1),`)
newline()
}
push(`_cache[${node.index}] = `)
genNode(node.value, context)
if (node.isVNode) {
if (node.isVOnce) {
push(`,`)
newline()
push(`${helper(SET_BLOCK_TRACKING)}(1),`)