Skip to content

Commit

Permalink
chore: improve BaseTransition (#4811)
Browse files Browse the repository at this point in the history
  • Loading branch information
caozhong1996 committed Nov 25, 2021
1 parent 89c54ee commit 4e1131e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
6 changes: 5 additions & 1 deletion packages/runtime-core/src/components/BaseTransition.ts
Expand Up @@ -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}`)
}

Expand Down
15 changes: 15 additions & 0 deletions packages/vue/__tests__/Transition.spec.ts
Expand Up @@ -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()
Expand Down

0 comments on commit 4e1131e

Please sign in to comment.