Skip to content

Commit 47ba33e

Browse files
committed
refactor: improve the fix for #4138
1 parent a8c3a8a commit 47ba33e

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

packages/shared/src/normalizeProp.ts

+7-5
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,16 @@ import { isNoUnitNumericStyleProp } from './domAttrConfig'
33

44
export type NormalizedStyle = Record<string, string | number>
55

6-
export function normalizeStyle(value: unknown): NormalizedStyle | undefined {
6+
export function normalizeStyle(
7+
value: unknown
8+
): NormalizedStyle | string | undefined {
79
if (isArray(value)) {
810
const res: NormalizedStyle = {}
911
for (let i = 0; i < value.length; i++) {
1012
const item = value[i]
11-
const normalized = normalizeStyle(
12-
isString(item) ? parseStringStyle(item) : item
13-
)
13+
const normalized = isString(item)
14+
? parseStringStyle(item)
15+
: (normalizeStyle(item) as NormalizedStyle)
1416
if (normalized) {
1517
for (const key in normalized) {
1618
res[key] = normalized[key]
@@ -19,7 +21,7 @@ export function normalizeStyle(value: unknown): NormalizedStyle | undefined {
1921
}
2022
return res
2123
} else if (isString(value)) {
22-
return parseStringStyle(value)
24+
return value
2325
} else if (isObject(value)) {
2426
return value
2527
}

0 commit comments

Comments
 (0)