wip: support resolving directives from setup scope variables by naming convention

v-my-dir can be resovled from setup scope variable named "vMyDir".
This commit is contained in:
Evan You
2020-11-23 16:32:24 -05:00
parent 2f32e4a077
commit ae2caad740
4 changed files with 121 additions and 35 deletions

View File

@@ -147,6 +147,29 @@ const bar = 1
assertCode(content)
})
test('referencing scope components and directives', () => {
const { content } = compile(
`
<script setup>
import ChildComp from './Child.vue'
import SomeOtherComp from './Other.vue'
import vMyDir from './my-dir'
</script>
<template>
<div v-my-dir></div>
<ChildComp/>
<some-other-comp/>
</template>
`,
{ inlineTemplate: true }
)
expect(content).toMatch('[_unref(vMyDir)]')
expect(content).toMatch('_createVNode(ChildComp)')
// kebab-case component support
expect(content).toMatch('_createVNode(SomeOtherComp)')
assertCode(content)
})
test('avoid unref() when necessary', () => {
// function, const, component import
const { content } = compile(