fix(Transition): fix validate duration (#1188)

This commit is contained in:
underfin
2020-05-18 22:09:10 +08:00
committed by GitHub
parent 8e30d0c74c
commit d73a508a73
3 changed files with 17 additions and 11 deletions

View File

@@ -7,7 +7,7 @@ import {
getCurrentInstance,
callWithAsyncErrorHandling
} from '@vue/runtime-core'
import { isObject } from '@vue/shared'
import { isObject, toNumber } from '@vue/shared'
import { ErrorCodes } from 'packages/runtime-core/src/errorHandling'
const TRANSITION = 'transition'
@@ -165,15 +165,15 @@ function normalizeDuration(
if (duration == null) {
return null
} else if (isObject(duration)) {
return [toNumber(duration.enter), toNumber(duration.leave)]
return [NumberOf(duration.enter), NumberOf(duration.leave)]
} else {
const n = toNumber(duration)
const n = NumberOf(duration)
return [n, n]
}
}
function toNumber(val: unknown): number {
const res = Number(val || 0)
function NumberOf(val: unknown): number {
const res = toNumber(val)
if (__DEV__) validateDuration(res)
return res
}