Skip to content

Commit eff4cab

Browse files
authored
fix(runtime-vapor): ensure vapor slot unmounting removes vnode slot content (#14520)
1 parent 7d079d5 commit eff4cab

2 files changed

Lines changed: 29 additions & 1 deletion

File tree

packages/runtime-vapor/__tests__/vdomInterop.spec.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1504,6 +1504,34 @@ describe('vdomInterop', () => {
15041504
await nextTick()
15051505
expect(html()).toBe('slot text<!--if-->')
15061506
})
1507+
1508+
test('unmounting vapor slot should remove vnode slot content', async () => {
1509+
const show = ref(true)
1510+
1511+
const VaporSlotOutlet = defineVaporComponent({
1512+
setup() {
1513+
return createSlot('default')
1514+
},
1515+
})
1516+
1517+
const { html } = define({
1518+
setup() {
1519+
return () =>
1520+
h('div', null, [
1521+
show.value
1522+
? h(VaporSlotOutlet as any, null, {
1523+
default: () => [h('span', 'slot vnode')],
1524+
})
1525+
: null,
1526+
])
1527+
},
1528+
}).render()
1529+
1530+
expect(html()).toBe('<div><span>slot vnode</span></div>')
1531+
show.value = false
1532+
await nextTick()
1533+
expect(html()).toBe('<div><!----></div>')
1534+
})
15071535
})
15081536

15091537
describe('Teleport', () => {

packages/runtime-vapor/src/vdomInterop.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -791,7 +791,7 @@ function renderVDOMSlot(
791791
if (currentBlock) {
792792
remove(currentBlock, parentNode)
793793
} else if (currentVNode) {
794-
internals.um(currentVNode, parentComponent as any, null)
794+
internals.um(currentVNode, parentComponent as any, null, true)
795795
}
796796
}
797797

0 commit comments

Comments
 (0)