File tree 2 files changed +26
-6
lines changed
2 files changed +26
-6
lines changed Original file line number Diff line number Diff line change @@ -22,6 +22,22 @@ test('should work', () => {
22
22
expect ( result . code ) . toMatch ( `export function render(` )
23
23
} )
24
24
25
+ // #6807
26
+ test ( 'should work with style comment' , ( ) => {
27
+ const source = `
28
+ <div style="
29
+ /* nothing */
30
+ width: 300px;
31
+ height: 100px/* nothing */
32
+ ">{{ render }}</div>
33
+ `
34
+
35
+ const result = compile ( { filename : 'example.vue' , source } )
36
+ expect ( result . errors . length ) . toBe ( 0 )
37
+ expect ( result . source ) . toBe ( source )
38
+ expect ( result . code ) . toMatch ( `{"width":"300px","height":"100px"}` )
39
+ } )
40
+
25
41
test ( 'preprocess pug' , ( ) => {
26
42
const template = parse (
27
43
`
Original file line number Diff line number Diff line change @@ -28,15 +28,19 @@ export function normalizeStyle(
28
28
29
29
const listDelimiterRE = / ; (? ! [ ^ ( ] * \) ) / g
30
30
const propertyDelimiterRE = / : ( [ ^ ] + ) /
31
+ const styleCommentRE = / \/ \* .* ?\* \/ / gs
31
32
32
33
export function parseStringStyle ( cssText : string ) : NormalizedStyle {
33
34
const ret : NormalizedStyle = { }
34
- cssText . split ( listDelimiterRE ) . forEach ( item => {
35
- if ( item ) {
36
- const tmp = item . split ( propertyDelimiterRE )
37
- tmp . length > 1 && ( ret [ tmp [ 0 ] . trim ( ) ] = tmp [ 1 ] . trim ( ) )
38
- }
39
- } )
35
+ cssText
36
+ . replace ( styleCommentRE , '' )
37
+ . split ( listDelimiterRE )
38
+ . forEach ( item => {
39
+ if ( item ) {
40
+ const tmp = item . split ( propertyDelimiterRE )
41
+ tmp . length > 1 && ( ret [ tmp [ 0 ] . trim ( ) ] = tmp [ 1 ] . trim ( ) )
42
+ }
43
+ } )
40
44
return ret
41
45
}
42
46
You can’t perform that action at this time.
0 commit comments