Skip to content

Commit 4e1131e

Browse files
authored
chore: improve BaseTransition (vuejs#4811)
1 parent 89c54ee commit 4e1131e

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,11 @@ const BaseTransitionImpl: ComponentOptions = {
161161
const rawProps = toRaw(props)
162162
const { mode } = rawProps
163163
// check mode
164-
if (__DEV__ && mode && !['in-out', 'out-in', 'default'].includes(mode)) {
164+
if (
165+
__DEV__ &&
166+
mode &&
167+
mode !== 'in-out' && mode !== 'out-in' && mode !== 'default'
168+
) {
165169
warn(`invalid <transition> mode: ${mode}`)
166170
}
167171

packages/vue/__tests__/Transition.spec.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1969,6 +1969,21 @@ describe('e2e: Transition', () => {
19691969
).toHaveBeenWarned()
19701970
})
19711971

1972+
test('warn when invalid transition mode', () => {
1973+
createApp({
1974+
template: `
1975+
<div id="container">
1976+
<transition name="test" mode="none">
1977+
<div class="test">content</div>
1978+
</transition>
1979+
</div>
1980+
`
1981+
}).mount(document.createElement('div'))
1982+
expect(
1983+
`invalid <transition> mode: none`
1984+
).toHaveBeenWarned()
1985+
})
1986+
19721987
// #3227
19731988
test(`HOC w/ merged hooks`, async () => {
19741989
const innerSpy = jest.fn()

0 commit comments

Comments
 (0)