mirror of
https://github.com/vuejs/vue.git
synced 2024-11-21 20:28:54 +00:00
feat: directive resolution for <script setup>
This commit is contained in:
parent
4b193390fb
commit
aa2b1f4d93
@ -102,7 +102,10 @@ function normalizeDirectives(
|
||||
dir.modifiers = emptyModifiers
|
||||
}
|
||||
res[getRawDirName(dir)] = dir
|
||||
dir.def = resolveAsset(vm.$options, 'directives', dir.name, true)
|
||||
if (vm._setupState && vm._setupState.__sfc) {
|
||||
dir.def = resolveAsset(vm, '_setupState', 'v-' + dir.name)
|
||||
}
|
||||
dir.def = dir.def || resolveAsset(vm.$options, 'directives', dir.name, true)
|
||||
}
|
||||
// $flow-disable-line
|
||||
return res
|
||||
|
@ -233,4 +233,18 @@ describe('api: setup context', () => {
|
||||
await nextTick()
|
||||
expect(vm.$el.outerHTML).toMatch(`<div>1</div>`)
|
||||
})
|
||||
|
||||
it('directive resolution', () => {
|
||||
const spy = vi.fn()
|
||||
new Vue({
|
||||
setup: () => ({
|
||||
__sfc: true,
|
||||
vDir: {
|
||||
inserted: spy
|
||||
}
|
||||
}),
|
||||
template: `<div v-dir />`
|
||||
}).$mount()
|
||||
expect(spy).toHaveBeenCalled()
|
||||
})
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user