fix(runtime-core): handle NaN identity check in v-memo (#5852)
fix #5853
This commit is contained in:
parent
d36ca4d80e
commit
a3881299e9
@ -210,4 +210,17 @@ describe('v-memo', () => {
|
|||||||
// should update
|
// should update
|
||||||
expect(el.innerHTML).toBe(`<div>2</div><div>2</div><div>2</div>`)
|
expect(el.innerHTML).toBe(`<div>2</div><div>2</div><div>2</div>`)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
test('v-memo dependency is NaN should be equal', async () => {
|
||||||
|
const [el, vm] = mount({
|
||||||
|
template: `<div v-memo="[x]">{{ y }}</div>`,
|
||||||
|
data: () => ({ x: NaN, y: 0 })
|
||||||
|
})
|
||||||
|
expect(el.innerHTML).toBe(`<div>0</div>`)
|
||||||
|
|
||||||
|
vm.y++
|
||||||
|
// should not update
|
||||||
|
await nextTick()
|
||||||
|
expect(el.innerHTML).toBe(`<div>0</div>`)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import { hasChanged } from '@vue/shared'
|
||||||
import { currentBlock, isBlockTreeEnabled, VNode } from '../vnode'
|
import { currentBlock, isBlockTreeEnabled, VNode } from '../vnode'
|
||||||
|
|
||||||
export function withMemo(
|
export function withMemo(
|
||||||
@ -22,8 +23,9 @@ export function isMemoSame(cached: VNode, memo: any[]) {
|
|||||||
if (prev.length != memo.length) {
|
if (prev.length != memo.length) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
for (let i = 0; i < prev.length; i++) {
|
for (let i = 0; i < prev.length; i++) {
|
||||||
if (prev[i] !== memo[i]) {
|
if (hasChanged(prev[i], memo[i])) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user