Skip to content

Commit b55846f

Browse files
committedNov 14, 2022
fix(shared): toNumber should only coerce strings
1 parent eb2a832 commit b55846f

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed
 

‎packages/runtime-core/src/components/Suspense.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,7 @@ function createSuspenseBoundary(
423423
o: { parentNode, remove }
424424
} = rendererInternals
425425

426-
const timeout = toNumber(vnode.props && vnode.props.timeout)
426+
const timeout = vnode.props ? toNumber(vnode.props.timeout) : undefined
427427
if (__DEV__) {
428428
assertNumber(timeout, `Suspense timeout`)
429429
}

‎packages/shared/src/index.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -163,10 +163,11 @@ export const looseToNumber = (val: any): any => {
163163
}
164164

165165
/**
166+
* Only conerces number-like strings
166167
* "123-foo" will be returned as-is
167168
*/
168169
export const toNumber = (val: any): any => {
169-
const n = Number(val)
170+
const n = isString(val) ? Number(val) : NaN
170171
return isNaN(n) ? val : n
171172
}
172173

0 commit comments

Comments
 (0)
Please sign in to comment.