Skip to content

Commit

Permalink
refactor: isVNode -> isVOnce
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed Jul 13, 2024
1 parent 2815531 commit 3107b57
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions packages/compiler-core/src/ast.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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,
}
}
Expand Down
4 changes: 2 additions & 2 deletions packages/compiler-core/src/codegen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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),`)
Expand Down

0 comments on commit 3107b57

Please sign in to comment.