chore: improve BaseTransition (#4811)

This commit is contained in:
Che Guevara 2021-11-25 18:42:24 +08:00 committed by GitHub
parent 89c54ee2b9
commit 4e1131e251
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 1 deletions

View File

@ -161,7 +161,11 @@ const BaseTransitionImpl: ComponentOptions = {
const rawProps = toRaw(props)
const { mode } = rawProps
// check mode
if (__DEV__ && mode && !['in-out', 'out-in', 'default'].includes(mode)) {
if (
__DEV__ &&
mode &&
mode !== 'in-out' && mode !== 'out-in' && mode !== 'default'
) {
warn(`invalid <transition> mode: ${mode}`)
}

View File

@ -1969,6 +1969,21 @@ describe('e2e: Transition', () => {
).toHaveBeenWarned()
})
test('warn when invalid transition mode', () => {
createApp({
template: `
<div id="container">
<transition name="test" mode="none">
<div class="test">content</div>
</transition>
</div>
`
}).mount(document.createElement('div'))
expect(
`invalid <transition> mode: none`
).toHaveBeenWarned()
})
// #3227
test(`HOC w/ merged hooks`, async () => {
const innerSpy = jest.fn()