Browse Source

chore: fix assertNumber for undefined value

pull/7212/head
Evan You 3 years ago
parent
commit
ce363e55a8
  1. 4
      packages/runtime-core/src/warning.ts
  2. 4
      packages/runtime-dom/src/components/Transition.ts

4
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.')

4
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
}

Loading…
Cancel
Save