feat: allow passing directive definition directly to h() (#12590)

This commit is contained in:
Kael 2022-07-04 14:08:41 +10:00 committed by Evan You
parent 427028ad89
commit d45bbeac27
2 changed files with 4 additions and 2 deletions

View File

@ -94,7 +94,7 @@ function normalizeDirectives(
// $flow-disable-line
return res
}
let i, dir
let i: number, dir: VNodeDirective
for (i = 0; i < dirs.length; i++) {
dir = dirs[i]
if (!dir.modifiers) {
@ -103,7 +103,7 @@ function normalizeDirectives(
}
res[getRawDirName(dir)] = dir
if (vm._setupState && vm._setupState.__sfc) {
dir.def = resolveAsset(vm, '_setupState', 'v-' + dir.name)
dir.def = dir.def || resolveAsset(vm, '_setupState', 'v-' + dir.name)
}
dir.def = dir.def || resolveAsset(vm.$options, 'directives', dir.name, true)
}

2
types/vnode.d.ts vendored
View File

@ -1,4 +1,5 @@
import { Vue } from './vue'
import { DirectiveFunction, DirectiveOptions } from './options'
export type ScopedSlot = (props: any) => ScopedSlotReturnValue
type ScopedSlotReturnValue =
@ -86,4 +87,5 @@ export interface VNodeDirective {
arg?: string
oldArg?: string
modifiers?: { [key: string]: boolean }
def?: DirectiveFunction | DirectiveOptions
}