Преглед изворни кода

chore: fix assertNumber for undefined value

Evan You пре 3 година
родитељ
комит
ce363e55a8

+ 3 - 1
packages/runtime-core/src/warning.ts

@@ -168,7 +168,9 @@ function formatProp(key: string, value: unknown, raw?: boolean): any {
  */
 export function assertNumber(val: unknown, type: string) {
   if (!__DEV__) return
-  if (typeof val !== 'number') {
+  if (val === undefined) {
+    return
+  } else if (typeof val !== 'number') {
     warn(`${type} is not a valid number - ` + `got ${JSON.stringify(val)}.`)
   } else if (isNaN(val)) {
     warn(`${type} is NaN - ` + 'the duration expression might be incorrect.')

+ 3 - 1
packages/runtime-dom/src/components/Transition.ts

@@ -283,7 +283,9 @@ function normalizeDuration(
 
 function NumberOf(val: unknown): number {
   const res = toNumber(val)
-  if (__DEV__) assertNumber(res, '<transition> explicit duration')
+  if (__DEV__) {
+    assertNumber(res, '<transition> explicit duration')
+  }
   return res
 }