Skip to content

Commit 5146fd8

Browse files
committed
feat: support css v-bind
1 parent 915eea6 commit 5146fd8

File tree

7 files changed

+39
-9
lines changed

7 files changed

+39
-9
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,6 @@
5959
"unbuild": "^0.7.4",
6060
"vite": "^2.9.12",
6161
"vitest": "^0.15.1",
62-
"vue": "^2.7.0-beta.2"
62+
"vue": "^2.7.0-beta.3"
6363
}
6464
}

playground/App.vue

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import TestCustomBlock from './custom/TestCustomBlock.vue'
99
import TestHmr from './hmr/TestHmr.vue'
1010
import TestAssets from './test-assets/TestAssets.vue'
1111
import TestES2020Features from './TestES2020Features.vue'
12+
import TestCssVBind from './css/TestCssVBind.vue'
1213
</script>
1314

1415
<template>
@@ -24,5 +25,6 @@ import TestES2020Features from './TestES2020Features.vue'
2425
<TestHmr />
2526
<TestAssets />
2627
<TestES2020Features />
28+
<TestCssVBind/>
2729
</div>
2830
</template>

playground/css/TestCssVBind.vue

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<script setup>
2+
import { ref } from 'vue'
3+
4+
const color = ref('red')
5+
</script>
6+
7+
<template>
8+
<div>
9+
<h2>CSS v-bind</h2>
10+
<span class="css-v-bind" @click="color = color === 'red' ? 'green' : 'red'"
11+
>This should be {{ color }}</span
12+
>
13+
</div>
14+
</template>
15+
16+
<style scoped>
17+
span {
18+
color: v-bind(color);
19+
}
20+
</style>

pnpm-lock.yaml

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/script.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ export function resolveScript(
3939

4040
resolved = options.compiler.compileScript(descriptor, {
4141
...options.script,
42+
id: descriptor.id,
4243
isProd: options.isProduction,
4344
sourceMap: options.sourceMap
4445
})

src/style.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export async function transformStyle(
1919
...options.style,
2020
filename: descriptor.filename,
2121
id: `data-v-${descriptor.id}`,
22-
// isProd: options.isProduction,
22+
isProd: options.isProduction,
2323
source: code,
2424
scoped: !!block.scoped,
2525
...(options.cssDevSourcemap

test/test.spec.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,4 +139,11 @@ export function declareTests(isBuild: boolean) {
139139
// )
140140
}
141141
})
142+
143+
test('css v-bind', async () => {
144+
const el = await getEl('.css-v-bind')
145+
expect(await getComputedColor(el!)).toBe(`rgb(255, 0, 0)`)
146+
await el!.click()
147+
expect(await getComputedColor(el!)).toBe(`rgb(0, 128, 0)`)
148+
})
142149
}

0 commit comments

Comments
 (0)