Skip to content

Commit 78966a5

Browse files
committed
test: test template parse options with ast reuse
1 parent 4a53b6f commit 78966a5

File tree

4 files changed

+29
-1
lines changed

4 files changed

+29
-1
lines changed

playground/vue/Main.vue

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
<PreCompiled />
3333
<PreCompiledExternalScoped />
3434
<PreCompiledExternalCssModules />
35+
<ParserOptions />
3536
</template>
3637

3738
<script setup lang="ts">
@@ -58,6 +59,7 @@ import DefaultLangs from './DefaultLangs.vue'
5859
import PreCompiled from './pre-compiled/foo.vue'
5960
import PreCompiledExternalScoped from './pre-compiled/external-scoped.vue'
6061
import PreCompiledExternalCssModules from './pre-compiled/external-cssmodules.vue'
62+
import ParserOptions from './ParserOptions.vue'
6163
6264
const TsGeneric = defineAsyncComponent(() => import('./TsGeneric.vue'))
6365

playground/vue/ParserOptions.vue

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<script setup>
2+
import { h } from 'vue'
3+
const MyElement = () => h('div', 'component')
4+
</script>
5+
6+
<template>
7+
<my-element class="custom-element-from-options">custom</my-element>
8+
</template>

playground/vue/__tests__/vue.spec.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,3 +363,11 @@ describe('pre-compiled components', () => {
363363
expect(await getColor('.pre-compiled-external-cssmodules')).toBe('red')
364364
})
365365
})
366+
367+
describe('template parse options', () => {
368+
test('isCustomElement', async () => {
369+
expect(await page.textContent('.custom-element-from-options')).toMatch(
370+
'custom',
371+
)
372+
})
373+
})

playground/vue/vite.config.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,17 @@ export default defineConfig({
99
'@': __dirname,
1010
},
1111
},
12-
plugins: [vuePlugin(), splitVendorChunkPlugin(), vueI18nPlugin],
12+
plugins: [
13+
vuePlugin({
14+
template: {
15+
compilerOptions: {
16+
isCustomElement: (tag) => tag.startsWith('my-'),
17+
},
18+
},
19+
}),
20+
splitVendorChunkPlugin(),
21+
vueI18nPlugin,
22+
],
1323
build: {
1424
// to make tests faster
1525
minify: false,

0 commit comments

Comments
 (0)