fix(shared): fix parsing of multi-line inline style (#6777)
This commit is contained in:
parent
99b6697fb4
commit
9768949ce0
|
@ -1,4 +1,4 @@
|
||||||
import { normalizeClass } from '../src'
|
import { normalizeClass, parseStringStyle } from '../src'
|
||||||
|
|
||||||
describe('normalizeClass', () => {
|
describe('normalizeClass', () => {
|
||||||
test('handles string correctly', () => {
|
test('handles string correctly', () => {
|
||||||
|
@ -16,4 +16,31 @@ describe('normalizeClass', () => {
|
||||||
'foo baz'
|
'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",
|
||||||
|
}
|
||||||
|
`)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
|
@ -27,7 +27,7 @@ export function normalizeStyle(
|
||||||
}
|
}
|
||||||
|
|
||||||
const listDelimiterRE = /;(?![^(]*\))/g
|
const listDelimiterRE = /;(?![^(]*\))/g
|
||||||
const propertyDelimiterRE = /:(.+)/
|
const propertyDelimiterRE = /:([^]+)/
|
||||||
|
|
||||||
export function parseStringStyle(cssText: string): NormalizedStyle {
|
export function parseStringStyle(cssText: string): NormalizedStyle {
|
||||||
const ret: NormalizedStyle = {}
|
const ret: NormalizedStyle = {}
|
||||||
|
|
Loading…
Reference in New Issue