|
@@ -3,14 +3,16 @@ import { isNoUnitNumericStyleProp } from './domAttrConfig'
|
|
|
|
|
|
|
|
export type NormalizedStyle = Record<string, string | number>
|
|
export type NormalizedStyle = Record<string, string | number>
|
|
|
|
|
|
|
|
-export function normalizeStyle(value: unknown): NormalizedStyle | undefined {
|
|
|
|
|
|
|
+export function normalizeStyle(
|
|
|
|
|
+ value: unknown
|
|
|
|
|
+): NormalizedStyle | string | undefined {
|
|
|
if (isArray(value)) {
|
|
if (isArray(value)) {
|
|
|
const res: NormalizedStyle = {}
|
|
const res: NormalizedStyle = {}
|
|
|
for (let i = 0; i < value.length; i++) {
|
|
for (let i = 0; i < value.length; i++) {
|
|
|
const item = value[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) {
|
|
if (normalized) {
|
|
|
for (const key in normalized) {
|
|
for (const key in normalized) {
|
|
|
res[key] = normalized[key]
|
|
res[key] = normalized[key]
|
|
@@ -19,7 +21,7 @@ export function normalizeStyle(value: unknown): NormalizedStyle | undefined {
|
|
|
}
|
|
}
|
|
|
return res
|
|
return res
|
|
|
} else if (isString(value)) {
|
|
} else if (isString(value)) {
|
|
|
- return parseStringStyle(value)
|
|
|
|
|
|
|
+ return value
|
|
|
} else if (isObject(value)) {
|
|
} else if (isObject(value)) {
|
|
|
return value
|
|
return value
|
|
|
}
|
|
}
|