Skip to content

Commit b0617e5

Browse files
committed
refactor: use index instead of function
1 parent 50126ca commit b0617e5

File tree

4 files changed

+7
-7
lines changed

4 files changed

+7
-7
lines changed

packages/runtime-core/src/component.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ export interface ComponentInternalInstance {
322322
* after initialized (e.g. inline handlers)
323323
* @internal
324324
*/
325-
renderCache: (Function | VNode)[]
325+
renderCache: (Function | VNode | undefined)[]
326326

327327
/**
328328
* Resolved component registry, only for components with mixins or extends

packages/runtime-core/src/helpers/withMemo.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@ export function withMemo(
1515

1616
// shallow clone
1717
ret.memo = memo.slice()
18-
19-
ret.cleanMemoCache = () => (cache[index] = undefined)
18+
ret.memoIndex = index
2019

2120
return (cache[index] = ret)
2221
}

packages/runtime-core/src/renderer.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -2110,15 +2110,16 @@ function baseCreateRenderer(
21102110
shapeFlag,
21112111
patchFlag,
21122112
dirs,
2113+
memoIndex,
21132114
} = vnode
21142115
// unset ref
21152116
if (ref != null) {
21162117
setRef(ref, null, parentSuspense, vnode, true)
21172118
}
21182119

21192120
// #6593 should clean memo cache when unmount
2120-
if (vnode.cleanMemoCache) {
2121-
vnode.cleanMemoCache()
2121+
if (memoIndex != null) {
2122+
parentComponent!.renderCache[memoIndex] = undefined
21222123
}
21232124

21242125
if (shapeFlag & ShapeFlags.COMPONENT_SHOULD_KEEP_ALIVE) {

packages/runtime-core/src/vnode.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -229,9 +229,9 @@ export interface VNode<
229229
*/
230230
memo?: any[]
231231
/**
232-
* @internal clean v-memo cache
232+
* @internal index for cleaning v-memo cache
233233
*/
234-
cleanMemoCache?: Function
234+
memoIndex?: number
235235
/**
236236
* @internal __COMPAT__ only
237237
*/

0 commit comments

Comments
 (0)