]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
fix(shared): fix parsing of multi-line inline style (#6777)
author三咲智子 Kevin Deng <sxzz@sxzz.moe>
Tue, 8 Nov 2022 03:17:50 +0000 (11:17 +0800)
committerGitHub <noreply@github.com>
Tue, 8 Nov 2022 03:17:50 +0000 (22:17 -0500)
packages/shared/__tests__/normalizeProp.spec.ts
packages/shared/src/normalizeProp.ts

index c884d9e7281edaad4265038a716bcac36cdc2231..4ef69503f047f3bf55d6100fd690de0ca8e0cf50 100644 (file)
@@ -1,4 +1,4 @@
-import { normalizeClass } from '../src'
+import { normalizeClass, parseStringStyle } from '../src'
 
 describe('normalizeClass', () => {
   test('handles string correctly', () => {
@@ -16,4 +16,31 @@ describe('normalizeClass', () => {
       'foo baz'
     )
   })
+
+  // #6777
+  test('parse multi-line inline style', () => {
+    expect(
+      parseStringStyle(`border: 1px solid transparent;
+    background: linear-gradient(white, white) padding-box,
+      repeating-linear-gradient(
+        -45deg,
+        #ccc 0,
+        #ccc 0.5em,
+        white 0,
+        white 0.75em
+      );`)
+    ).toMatchInlineSnapshot(`
+      Object {
+        "background": "linear-gradient(white, white) padding-box,
+            repeating-linear-gradient(
+              -45deg,
+              #ccc 0,
+              #ccc 0.5em,
+              white 0,
+              white 0.75em
+            )",
+        "border": "1px solid transparent",
+      }
+    `)
+  })
 })
index 283309a43691faf512fabc05f28847c830896988..b4010eb635089a3ea425d90264b7c90183057ae8 100644 (file)
@@ -27,7 +27,7 @@ export function normalizeStyle(
 }
 
 const listDelimiterRE = /;(?![^(]*\))/g
-const propertyDelimiterRE = /:(.+)/
+const propertyDelimiterRE = /:([^]+)/
 
 export function parseStringStyle(cssText: string): NormalizedStyle {
   const ret: NormalizedStyle = {}