Skip to content

Commit

Permalink
chore: fix assertNumber for undefined value
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed Nov 14, 2022
1 parent 7d0c63f commit ce363e5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion packages/runtime-core/src/warning.ts
Expand Up @@ -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.')
Expand Down
4 changes: 3 additions & 1 deletion packages/runtime-dom/src/components/Transition.ts
Expand Up @@ -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
}

Expand Down

0 comments on commit ce363e5

Please sign in to comment.