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

View File

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