]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
refactor: improve the fix for #4138
authorEvan You <yyx990803@gmail.com>
Mon, 19 Jul 2021 14:43:14 +0000 (10:43 -0400)
committerEvan You <yyx990803@gmail.com>
Mon, 19 Jul 2021 14:43:14 +0000 (10:43 -0400)
packages/shared/src/normalizeProp.ts

index 7d4ba83a92309f500de1aa3e02db0a08a7421bf3..ec765be0f9e4d2d24941a26a09d147870889b388 100644 (file)
@@ -3,14 +3,16 @@ import { isNoUnitNumericStyleProp } from './domAttrConfig'
 
 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)) {
     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
   }