mirror of
https://gitee.com/vuejs/vue.git
synced 2024-12-04 13:07:40 +08:00
should invoke destroy hook for replaced root nodes too
This commit is contained in:
parent
5aeb7f5eef
commit
99a96d3c37
@ -383,6 +383,8 @@ export function createPatchFunction (backend) {
|
||||
if (parent !== null) {
|
||||
nodeOps.insertBefore(parent, vnode.elm, nodeOps.nextSibling(elm))
|
||||
removeVnodes(parent, [oldVnode], 0, 0)
|
||||
} else if (isDef(oldVnode.tag)) {
|
||||
invokeDestroyHook(oldVnode)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -244,9 +244,10 @@ describe('hooks', () => {
|
||||
])
|
||||
const vnode2 = new VNode('div')
|
||||
patch1(vnode0, vnode1)
|
||||
expect(destroyed).toBe(1) // should invoke for replaced root nodes too
|
||||
patch1(vnode1, vnode2)
|
||||
expect(created).toBe(5)
|
||||
expect(destroyed).toBe(4)
|
||||
expect(destroyed).toBe(5)
|
||||
})
|
||||
|
||||
it('should not invoke `create` and `remove` module hook for text nodes', () => {
|
||||
@ -293,9 +294,10 @@ describe('hooks', () => {
|
||||
])
|
||||
const vnode2 = new VNode('div')
|
||||
patch1(vnode0, vnode1)
|
||||
expect(destroyed).toBe(1) // should invoke for replaced root nodes too
|
||||
patch1(vnode1, vnode2)
|
||||
expect(created).toBe(5)
|
||||
expect(destroyed).toBe(4)
|
||||
expect(destroyed).toBe(5)
|
||||
})
|
||||
|
||||
it('should call `create` listener before inserted into parent but after children', () => {
|
||||
|
Loading…
Reference in New Issue
Block a user