fix(components): width reset to empty string should be parsed to auto (#5186)

fix #4878
This commit is contained in:
神楽坂みずき 2022-01-07 16:02:32 +08:00 committed by GitHub
parent 2af36e42b2
commit e7d71cce2b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -194,20 +194,22 @@ export function mergeOptions<T, K>(defaults: T, config: K): T & K {
return options
}
export function parseWidth(width: number | string): number {
export function parseWidth(width: number | string): number | string {
if (width === '') return width
if (width !== undefined) {
width = parseInt(width as string, 10)
if (isNaN(width)) {
width = null
if (Number.isNaN(width)) {
width = ''
}
}
return +width
return width
}
export function parseMinWidth(minWidth): number {
if (typeof minWidth !== 'undefined') {
export function parseMinWidth(minWidth: number | string): number | string {
if (minWidth === '') return minWidth
if (minWidth !== undefined) {
minWidth = parseWidth(minWidth)
if (isNaN(minWidth)) {
if (Number.isNaN(minWidth)) {
minWidth = 80
}
}