Skip to content

Commit 67a0290

Browse files
authored
fix(transition): toggling branches with in-out mode should be transitioned correctly (#3109)
fix #3104
1 parent b2e00f0 commit 67a0290

File tree

2 files changed

+23
-8
lines changed

2 files changed

+23
-8
lines changed

packages/runtime-core/__tests__/components/BaseTransition.spec.ts

+22-7
Original file line numberDiff line numberDiff line change
@@ -247,14 +247,17 @@ describe('BaseTransition', () => {
247247
})
248248

249249
describe('toggle on-off', () => {
250-
async function testToggleOnOff({
251-
trueBranch,
252-
trueSerialized,
253-
falseBranch,
254-
falseSerialized
255-
}: ToggleOptions) {
250+
async function testToggleOnOff(
251+
{
252+
trueBranch,
253+
trueSerialized,
254+
falseBranch,
255+
falseSerialized
256+
}: ToggleOptions,
257+
mode?: BaseTransitionProps['mode']
258+
) {
256259
const toggle = ref(true)
257-
const { props, cbs } = mockProps()
260+
const { props, cbs } = mockProps({ mode })
258261
const root = mount(
259262
props,
260263
() => (toggle.value ? trueBranch() : falseBranch())
@@ -322,6 +325,18 @@ describe('BaseTransition', () => {
322325
falseSerialized: `<!---->`
323326
})
324327
})
328+
329+
test('w/ mode: "in-out', async () => {
330+
await testToggleOnOff(
331+
{
332+
trueBranch: () => h('div'),
333+
trueSerialized: `<div></div>`,
334+
falseBranch: () => null,
335+
falseSerialized: `<!---->`
336+
},
337+
'in-out'
338+
)
339+
})
325340
})
326341

327342
describe('toggle on-off before finish', () => {

packages/runtime-core/src/components/BaseTransition.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ const BaseTransitionImpl = {
223223
instance.update()
224224
}
225225
return emptyPlaceholder(child)
226-
} else if (mode === 'in-out') {
226+
} else if (mode === 'in-out' && innerChild.type !== Comment) {
227227
leavingHooks.delayLeave = (
228228
el: TransitionElement,
229229
earlyRemove,

0 commit comments

Comments
 (0)