]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
chore: improve BaseTransition (#4811)
authorChe Guevara <836934184@qq.com>
Thu, 25 Nov 2021 10:42:24 +0000 (18:42 +0800)
committerGitHub <noreply@github.com>
Thu, 25 Nov 2021 10:42:24 +0000 (05:42 -0500)
packages/runtime-core/src/components/BaseTransition.ts
packages/vue/__tests__/Transition.spec.ts

index cb628bf655aede199c0796c7f531394b57077c07..27bfb5f523aa02baebc95b57f920f0ee2918da5b 100644 (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}`)
       }
 
index bcb1fcb3b0a2388a1368a726e13152f66a8c3a1c..97b3ccd96257544e9547ad74407e984bdc81a53a 100644 (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()