From e7d71cce2bf9c85e7b533772c12928a13135eb0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A5=9E=E6=A5=BD=E5=9D=82=E3=81=BF=E3=81=9A=E3=81=8D?= <45122329+cokemine@users.noreply.github.com> Date: Fri, 7 Jan 2022 16:02:32 +0800 Subject: [PATCH] fix(components): width reset to empty string should be parsed to auto (#5186) fix #4878 --- packages/components/table/src/util.ts | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/packages/components/table/src/util.ts b/packages/components/table/src/util.ts index 9eb002511b..66e94205c3 100644 --- a/packages/components/table/src/util.ts +++ b/packages/components/table/src/util.ts @@ -194,20 +194,22 @@ export function mergeOptions(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 } }