fix(compiler-sfc): fix css v-bind inside other css functions
fix #5302, close #5306
This commit is contained in:
@@ -74,14 +74,16 @@ export default {
|
||||
expose();
|
||||
|
||||
_useCssVars(_ctx => ({
|
||||
\\"xxxxxxxx-_a___b____2____px__\\": ((_unref(a) + _unref(b)) / 2 + 'px' ),
|
||||
\\"xxxxxxxx-foo\\": (_unref(foo)),
|
||||
\\"xxxxxxxx-_a___b____2____px_\\": ((_unref(a) + _unref(b)) / 2 + 'px'),
|
||||
\\"xxxxxxxx-__a___b______2___a_\\": (((_unref(a) + _unref(b))) / (2 * _unref(a)))
|
||||
}))
|
||||
|
||||
let a = 100
|
||||
let b = 200
|
||||
let foo = 300
|
||||
|
||||
return { a, b }
|
||||
return { a, b, foo }
|
||||
}
|
||||
|
||||
}"
|
||||
|
||||
@@ -204,8 +204,13 @@ describe('CSS vars injection', () => {
|
||||
`<script setup>
|
||||
let a = 100
|
||||
let b = 200
|
||||
let foo = 300
|
||||
</script>\n` +
|
||||
`<style>
|
||||
p{
|
||||
width: calc(v-bind(foo) - 3px);
|
||||
height: calc(v-bind('foo') - 3px);
|
||||
}
|
||||
div {
|
||||
color: v-bind((a + b) / 2 + 'px' );
|
||||
}
|
||||
@@ -218,7 +223,8 @@ describe('CSS vars injection', () => {
|
||||
</style>`
|
||||
)
|
||||
expect(content).toMatch(`_useCssVars(_ctx => ({
|
||||
"${mockId}-_a___b____2____px__": ((_unref(a) + _unref(b)) / 2 + 'px' ),
|
||||
"${mockId}-foo": (_unref(foo)),
|
||||
"${mockId}-_a___b____2____px_": ((_unref(a) + _unref(b)) / 2 + 'px'),
|
||||
"${mockId}-__a___b______2___a_": (((_unref(a) + _unref(b))) / (2 * _unref(a)))
|
||||
})`)
|
||||
assertCode(content)
|
||||
|
||||
Reference in New Issue
Block a user