Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: directives shorthand normalize error (fix #12743) #12744

Merged
merged 2 commits into from Aug 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/core/vdom/modules/directives.ts
Expand Up @@ -103,7 +103,15 @@ function normalizeDirectives(
}
res[getRawDirName(dir)] = dir
if (vm._setupState && vm._setupState.__sfc) {
dir.def = dir.def || resolveAsset(vm, '_setupState', 'v-' + dir.name)
const setupDef = dir.def || resolveAsset(vm, '_setupState', 'v-' + dir.name)
if (typeof setupDef === 'function') {
dir.def = {
bind: setupDef,
update: setupDef,
}
} else {
dir.def = setupDef
}
}
dir.def = dir.def || resolveAsset(vm.$options, 'directives', dir.name, true)
}
Expand Down
13 changes: 13 additions & 0 deletions test/unit/features/v3/apiSetup.spec.ts
Expand Up @@ -251,6 +251,19 @@ describe('api: setup context', () => {
expect(spy).toHaveBeenCalled()
})

// #12743
it('directive resolution for shorthand', () => {
const spy = vi.fn()
new Vue({
setup: () => ({
__sfc: true,
vDir: spy
}),
template: `<div v-dir />`
}).$mount()
expect(spy).toHaveBeenCalled()
})

// #12561
it('setup props should be reactive', () => {
const msg = ref('hi')
Expand Down