fix(compiler-sfc): duplicated injected css var with repeated vars in style (#2802)

This commit is contained in:
patak
2021-07-15 22:45:37 +02:00
committed by GitHub
parent b31712ecc5
commit 29010501cc
3 changed files with 44 additions and 1 deletions

View File

@@ -160,5 +160,26 @@ describe('CSS vars injection', () => {
).content
)
})
test('w/ <script setup> using the same var multiple times', () => {
const { content } = compileSFCScript(
`<script setup>
const color = 'red'
</script>\n` +
`<style>
div {
color: v-bind(color);
}
p {
color: v-bind(color);
}
</style>`
)
// color should only be injected once, even if it is twice in style
expect(content).toMatch(`_useCssVars(_ctx => ({
"${mockId}-color": (color)
})`)
assertCode(content)
})
})
})