From 47ba33e27b93f789b1f30fc34fab119c852d10fd Mon Sep 17 00:00:00 2001 From: Evan You Date: Mon, 19 Jul 2021 10:43:14 -0400 Subject: [PATCH] refactor: improve the fix for #4138 --- packages/shared/src/normalizeProp.ts | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/packages/shared/src/normalizeProp.ts b/packages/shared/src/normalizeProp.ts index 7d4ba83a923..ec765be0f9e 100644 --- a/packages/shared/src/normalizeProp.ts +++ b/packages/shared/src/normalizeProp.ts @@ -3,14 +3,16 @@ import { isNoUnitNumericStyleProp } from './domAttrConfig' export type NormalizedStyle = Record -export function normalizeStyle(value: unknown): NormalizedStyle | undefined { +export function normalizeStyle( + value: unknown +): NormalizedStyle | string | undefined { if (isArray(value)) { const res: NormalizedStyle = {} for (let i = 0; i < value.length; i++) { const item = value[i] - const normalized = normalizeStyle( - isString(item) ? parseStringStyle(item) : item - ) + const normalized = isString(item) + ? parseStringStyle(item) + : (normalizeStyle(item) as NormalizedStyle) if (normalized) { for (const key in normalized) { res[key] = normalized[key] @@ -19,7 +21,7 @@ export function normalizeStyle(value: unknown): NormalizedStyle | undefined { } return res } else if (isString(value)) { - return parseStringStyle(value) + return value } else if (isObject(value)) { return value }