fix(runtime-core): fix duplicated unmount traversal in optimized mode
fix #2169
This commit is contained in:
@@ -14,7 +14,8 @@ import {
|
||||
nextTick,
|
||||
defineComponent,
|
||||
withCtx,
|
||||
renderSlot
|
||||
renderSlot,
|
||||
onBeforeUnmount
|
||||
} from '@vue/runtime-test'
|
||||
import { PatchFlags, SlotFlags } from '@vue/shared'
|
||||
|
||||
@@ -449,4 +450,29 @@ describe('renderer: optimized mode', () => {
|
||||
|
||||
expect(inner(root)).toBe('<div><p>1</p></div>')
|
||||
})
|
||||
|
||||
// #2169
|
||||
// block
|
||||
// - dynamic child (1)
|
||||
// - component (2)
|
||||
// When unmounting (1), we know we are in optimized mode so no need to further
|
||||
// traverse unmount its children
|
||||
test('should not perform unnecessary unmount traversals', () => {
|
||||
const spy = jest.fn()
|
||||
const Child = {
|
||||
setup() {
|
||||
onBeforeUnmount(spy)
|
||||
return () => 'child'
|
||||
}
|
||||
}
|
||||
const Parent = () => (
|
||||
openBlock(),
|
||||
createBlock('div', null, [
|
||||
createVNode('div', { style: {} }, [createVNode(Child)], 4 /* STYLE */)
|
||||
])
|
||||
)
|
||||
render(h(Parent), root)
|
||||
render(null, root)
|
||||
expect(spy).toHaveBeenCalledTimes(1)
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user