fix(compiler-sfc): use prependLeft to handle CSSVars (#7760)

This commit is contained in:
白雾三语 2023-03-28 17:47:10 +08:00 committed by GitHub
parent b9dc1adefb
commit 139104ba26
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 17 additions and 0 deletions

View File

@ -255,5 +255,22 @@ describe('CSS vars injection', () => {
)
expect(cssVars).toMatchObject([`count.toString(`, `xxx`])
})
// #7759
test('It should correctly parse the case where there is no space after the script tag', () => {
const { content } = compileSFCScript(
`<script setup>import { ref as _ref } from 'vue';
let background = _ref('red')
</script>
<style>
label {
background: v-bind(background);
}
</style>`
)
expect(content).toMatch(
`export default {\n setup(__props, { expose }) {\n expose();\n\n_useCssVars(_ctx => ({\n "xxxxxxxx-background": (_unref(background))\n}))`
)
})
})
})