feat(runtime-core): support dynamic / external array in v-memo (#4255)

This commit is contained in:
lidlanca
2021-08-09 15:39:22 -04:00
committed by GitHub
parent 2641422aa7
commit 6779bff537
2 changed files with 47 additions and 1 deletions

View File

@@ -11,12 +11,17 @@ export function withMemo(
return cached
}
const ret = render()
ret.memo = memo
// shallow clone
ret.memo = memo.slice()
return (cache[index] = ret)
}
export function isMemoSame(cached: VNode, memo: any[]) {
const prev: any[] = cached.memo!
if (prev.length != memo.length) {
return false
}
for (let i = 0; i < prev.length; i++) {
if (prev[i] !== memo[i]) {
return false