File tree Expand file tree Collapse file tree 2 files changed +13
-5
lines changed Expand file tree Collapse file tree 2 files changed +13
-5
lines changed Original file line number Diff line number Diff line change @@ -105,18 +105,24 @@ describe('CSS vars injection', () => {
105
105
`<style>div{
106
106
color: v-bind(color);
107
107
font-size: v-bind('font.size');
108
+ width: v-bind(width, 100%);
109
+ font-weight: v-bind('font.weight', bold);
108
110
}</style>` ,
109
111
{ isProd : true } ,
110
112
)
111
113
expect ( content ) . toMatch ( `_useCssVars(_ctx => ({
112
114
"4003f1a6": (_ctx.color),
113
- "41b6490a": (_ctx.font.size)
115
+ "41b6490a": (_ctx.font.size),
116
+ "3dd5f4e0": (_ctx.width),
117
+ "9848e57e": (_ctx.font.weight)
114
118
}))}` )
115
119
116
120
const { code } = compileStyle ( {
117
121
source : `.foo {
118
122
color: v-bind(color);
119
123
font-size: v-bind('font.size');
124
+ width: v-bind(width, 100%);
125
+ font-weight: v-bind('font.weight', bold);
120
126
}` ,
121
127
filename : 'test.css' ,
122
128
id : mockId ,
@@ -126,6 +132,8 @@ describe('CSS vars injection', () => {
126
132
".foo {
127
133
color: var(--4003f1a6);
128
134
font-size: var(--41b6490a);
135
+ width: var(--3dd5f4e0, 100%);
136
+ font-weight: var(--9848e57e, bold);
129
137
}"
130
138
` )
131
139
} )
Original file line number Diff line number Diff line change @@ -98,9 +98,9 @@ function lexBinding(content: string, start: number): number | null {
98
98
state = LexerState . inDoubleQuoteString
99
99
} else if ( char === `(` ) {
100
100
parenDepth ++
101
- } else if ( char === `)` ) {
101
+ } else if ( char === `)` || char === ',' ) {
102
102
if ( parenDepth > 0 ) {
103
- parenDepth --
103
+ char === `)` && parenDepth --
104
104
} else {
105
105
return i
106
106
}
@@ -146,8 +146,8 @@ export const cssVarsPlugin: PluginCreator<CssVarsPluginOptions> = opts => {
146
146
const variable = normalizeExpression ( value . slice ( start , end ) )
147
147
transformed +=
148
148
value . slice ( lastIndex , match . index ) +
149
- `var(--${ genVarName ( id , variable , isProd ) } ) `
150
- lastIndex = end + 1
149
+ `var(--${ genVarName ( id , variable , isProd ) } `
150
+ lastIndex = end
151
151
}
152
152
}
153
153
decl . value = transformed + value . slice ( lastIndex )
You can’t perform that action at this time.
0 commit comments