( memo: any[], render: () => VNode<any, any>, cache: any[], index: number, )
| 2 | import { type VNode, currentBlock, isBlockTreeEnabled } from '../vnode' |
| 3 | |
| 4 | export function withMemo( |
| 5 | memo: any[], |
| 6 | render: () => VNode<any, any>, |
| 7 | cache: any[], |
| 8 | index: number, |
| 9 | ): VNode<any, any> { |
| 10 | const cached = cache[index] as VNode | undefined |
| 11 | if (cached && isMemoSame(cached, memo)) { |
| 12 | return cached |
| 13 | } |
| 14 | const ret = render() |
| 15 | |
| 16 | // shallow clone |
| 17 | ret.memo = memo.slice() |
| 18 | ret.cacheIndex = index |
| 19 | |
| 20 | return (cache[index] = ret) |
| 21 | } |
| 22 | |
| 23 | export function isMemoSame(cached: VNode, memo: any[]): boolean { |
| 24 | const prev: any[] = cached.memo! |
nothing calls this directly
no test coverage detected