Skip to content

Commit d3be633

Browse files
committed
fix(compiler-core): add cache flag for createTextVNode
1 parent 347ef1d commit d3be633

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

packages/compiler-core/__tests__/transforms/__snapshots__/cacheStatic.spec.ts.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ return function render(_ctx, _cache) {
6060
6161
return (_openBlock(), _createElementBlock("div", null, _cache[0] || (_cache[0] = [
6262
_createElementVNode("span", null, null, -1 /* CACHED */),
63-
_createTextVNode("foo"),
63+
_createTextVNode("foo", -1 /* CACHED */),
6464
_createElementVNode("div", null, null, -1 /* CACHED */)
6565
])))
6666
}

packages/compiler-core/src/transforms/cacheStatic.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,13 @@ import {
2424
getVNodeHelper,
2525
} from '../ast'
2626
import type { TransformContext } from '../transform'
27-
import { PatchFlags, isArray, isString, isSymbol } from '@vue/shared'
27+
import {
28+
PatchFlagNames,
29+
PatchFlags,
30+
isArray,
31+
isString,
32+
isSymbol,
33+
} from '@vue/shared'
2834
import { findDir, isSlotOutlet } from '../utils'
2935
import {
3036
GUARD_REACTIVE_PROPS,
@@ -109,6 +115,12 @@ function walk(
109115
? ConstantTypes.NOT_CONSTANT
110116
: getConstantType(child, context)
111117
if (constantType >= ConstantTypes.CAN_CACHE) {
118+
if (child.codegenNode.type === NodeTypes.JS_CALL_EXPRESSION) {
119+
child.codegenNode.arguments.push(
120+
PatchFlags.CACHED +
121+
(__DEV__ ? ` /* ${PatchFlagNames[PatchFlags.CACHED]} */` : ``),
122+
)
123+
}
112124
toCache.push(child)
113125
continue
114126
}

0 commit comments

Comments
 (0)