Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions packages/runtime-core/__tests__/rendererOptimizedMode.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -487,6 +487,32 @@ describe('renderer: optimized mode', () => {
expect(spy).toHaveBeenCalledTimes(1)
})

test('should call onUnmounted hook for dynamic components receiving an existing vnode w/ component children', async () => {
const spy = vi.fn()
const show = ref(1)
const Child = {
setup() {
onUnmounted(spy)
return () => 'child'
},
}
const foo = h('div', null, h(Child))
const app = createApp({
render() {
return show.value
? (openBlock(),
createBlock('div', null, [(openBlock(), createBlock(foo))]))
: createCommentVNode('v-if', true)
},
})

app.mount(root)
show.value = 0
await nextTick()

expect(spy).toHaveBeenCalledTimes(1)
})

// #2444
// `KEYED_FRAGMENT` and `UNKEYED_FRAGMENT` always need to diff its children
test('non-stable Fragment always need to diff its children', () => {
Expand Down
5 changes: 5 additions & 0 deletions packages/runtime-core/src/renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2112,6 +2112,11 @@ function baseCreateRenderer(
dirs,
memoIndex,
} = vnode

if (patchFlag === PatchFlags.BAIL) {
optimized = false
}

// unset ref
if (ref != null) {
setRef(ref, null, parentSuspense, vnode, true)
Expand Down