Skip to content

Commit b2e450e

Browse files
committed
fix: always spread cached array
1 parent b6f0b7b commit b2e450e

File tree

3 files changed

+3
-13
lines changed

3 files changed

+3
-13
lines changed

packages/compiler-core/src/ast.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,6 @@ export interface CacheExpression extends Node {
420420
needPauseTracking: boolean
421421
inVOnce: boolean
422422
needArraySpread: boolean
423-
cachedAsArray: boolean
424423
}
425424

426425
export interface MemoExpression extends CallExpression {
@@ -785,7 +784,6 @@ export function createCacheExpression(
785784
needPauseTracking: needPauseTracking,
786785
inVOnce,
787786
needArraySpread: false,
788-
cachedAsArray: false,
789787
loc: locStub,
790788
}
791789
}

packages/compiler-core/src/codegen.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1012,11 +1012,10 @@ function genConditionalExpression(
10121012

10131013
function genCacheExpression(node: CacheExpression, context: CodegenContext) {
10141014
const { push, helper, indent, deindent, newline } = context
1015-
const { needPauseTracking, needArraySpread, cachedAsArray } = node
1015+
const { needPauseTracking, needArraySpread } = node
10161016
if (needArraySpread) {
10171017
push(`[...(`)
10181018
}
1019-
if (cachedAsArray) push(`(`)
10201019
push(`_cache[${node.index}] || (`)
10211020
if (needPauseTracking) {
10221021
indent()
@@ -1028,7 +1027,6 @@ function genCacheExpression(node: CacheExpression, context: CodegenContext) {
10281027
}
10291028
push(`_cache[${node.index}] = `)
10301029
genNode(node.value, context)
1031-
if (cachedAsArray) push(`).slice()`)
10321030
if (needPauseTracking) {
10331031
push(`).cacheIndex = ${node.index},`)
10341032
newline()

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

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -214,18 +214,12 @@ function walk(
214214
}
215215
}
216216

217-
function getCacheExpression(
218-
value: JSChildNode,
219-
cachedAsArray: boolean = true,
220-
): CacheExpression {
217+
function getCacheExpression(value: JSChildNode): CacheExpression {
221218
const exp = context.cache(value)
222219
// #6978, #7138, #7114
223220
// a cached children array inside v-for can caused HMR errors since
224221
// it might be mutated when mounting the first item
225-
if (inFor && context.hmr) {
226-
exp.needArraySpread = true
227-
}
228-
exp.cachedAsArray = cachedAsArray
222+
exp.needArraySpread = true
229223
return exp
230224
}
231225

0 commit comments

Comments
 (0)