Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(transition): toggling branches with in-out mode should be transitioned correctly #3109

Merged
merged 1 commit into from
Mar 22, 2021
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
29 changes: 22 additions & 7 deletions packages/runtime-core/__tests__/components/BaseTransition.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down Expand Up @@ -322,6 +325,18 @@ describe('BaseTransition', () => {
falseSerialized: `<!---->`
})
})

test('w/ mode: "in-out', async () => {
await testToggleOnOff(
{
trueBranch: () => h('div'),
trueSerialized: `<div></div>`,
falseBranch: () => null,
falseSerialized: `<!---->`
},
'in-out'
)
})
})

describe('toggle on-off before finish', () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/runtime-core/src/components/BaseTransition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down