From: HcySunYang Date: Mon, 22 Mar 2021 20:56:24 +0000 (+0800) Subject: fix(transition): toggling branches with in-out mode should be transitioned correctly... X-Git-Tag: v3.0.8~47 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=67a0290c0aa5626dbc71b66b00e7ca7755e339cb;p=thirdparty%2Fvuejs%2Fcore.git fix(transition): toggling branches with in-out mode should be transitioned correctly (#3109) fix #3104 --- diff --git a/packages/runtime-core/__tests__/components/BaseTransition.spec.ts b/packages/runtime-core/__tests__/components/BaseTransition.spec.ts index ccb1ae6172..dcc8105bfe 100644 --- a/packages/runtime-core/__tests__/components/BaseTransition.spec.ts +++ b/packages/runtime-core/__tests__/components/BaseTransition.spec.ts @@ -247,14 +247,17 @@ describe('BaseTransition', () => { }) describe('toggle on-off', () => { - async function testToggleOnOff({ - trueBranch, - trueSerialized, - falseBranch, - falseSerialized - }: ToggleOptions) { + async function testToggleOnOff( + { + trueBranch, + trueSerialized, + falseBranch, + falseSerialized + }: ToggleOptions, + mode?: BaseTransitionProps['mode'] + ) { const toggle = ref(true) - const { props, cbs } = mockProps() + const { props, cbs } = mockProps({ mode }) const root = mount( props, () => (toggle.value ? trueBranch() : falseBranch()) @@ -322,6 +325,18 @@ describe('BaseTransition', () => { falseSerialized: `` }) }) + + test('w/ mode: "in-out', async () => { + await testToggleOnOff( + { + trueBranch: () => h('div'), + trueSerialized: `
`, + falseBranch: () => null, + falseSerialized: `` + }, + 'in-out' + ) + }) }) describe('toggle on-off before finish', () => { diff --git a/packages/runtime-core/src/components/BaseTransition.ts b/packages/runtime-core/src/components/BaseTransition.ts index 674eb79561..a6f2fb27f3 100644 --- a/packages/runtime-core/src/components/BaseTransition.ts +++ b/packages/runtime-core/src/components/BaseTransition.ts @@ -223,7 +223,7 @@ const BaseTransitionImpl = { instance.update() } return emptyPlaceholder(child) - } else if (mode === 'in-out') { + } else if (mode === 'in-out' && innerChild.type !== Comment) { leavingHooks.delayLeave = ( el: TransitionElement, earlyRemove,