]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
fix(compiler-sfc): use prependLeft to handle CSSVars (#7760)
author白雾三语 <32354856+baiwusanyu-c@users.noreply.github.com>
Tue, 28 Mar 2023 09:47:10 +0000 (17:47 +0800)
committerGitHub <noreply@github.com>
Tue, 28 Mar 2023 09:47:10 +0000 (17:47 +0800)
packages/compiler-sfc/__tests__/cssVars.spec.ts

index ffa5d4e798b468ec866c5224864ab901c820cbcb..05e5f689ac9008578301563bfe7fd1c870a552b1 100644 (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}))`
+      )
+    })
   })
 })