mirror of https://github.com/vuejs/core.git
fix(shared): toNumber should only coerce strings
This commit is contained in:
parent
eb2a83283c
commit
b55846f05c
|
@ -423,7 +423,7 @@ function createSuspenseBoundary(
|
|||
o: { parentNode, remove }
|
||||
} = rendererInternals
|
||||
|
||||
const timeout = toNumber(vnode.props && vnode.props.timeout)
|
||||
const timeout = vnode.props ? toNumber(vnode.props.timeout) : undefined
|
||||
if (__DEV__) {
|
||||
assertNumber(timeout, `Suspense timeout`)
|
||||
}
|
||||
|
|
|
@ -163,10 +163,11 @@ export const looseToNumber = (val: any): any => {
|
|||
}
|
||||
|
||||
/**
|
||||
* Only conerces number-like strings
|
||||
* "123-foo" will be returned as-is
|
||||
*/
|
||||
export const toNumber = (val: any): any => {
|
||||
const n = Number(val)
|
||||
const n = isString(val) ? Number(val) : NaN
|
||||
return isNaN(n) ? val : n
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue