Skip to content

Commit d45bbea

Browse files
KaelWDyyx990803
authored andcommitted
feat: allow passing directive definition directly to h() (#12590)
1 parent 427028a commit d45bbea

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

src/core/vdom/modules/directives.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ function normalizeDirectives(
9494
// $flow-disable-line
9595
return res
9696
}
97-
let i, dir
97+
let i: number, dir: VNodeDirective
9898
for (i = 0; i < dirs.length; i++) {
9999
dir = dirs[i]
100100
if (!dir.modifiers) {
@@ -103,7 +103,7 @@ function normalizeDirectives(
103103
}
104104
res[getRawDirName(dir)] = dir
105105
if (vm._setupState && vm._setupState.__sfc) {
106-
dir.def = resolveAsset(vm, '_setupState', 'v-' + dir.name)
106+
dir.def = dir.def || resolveAsset(vm, '_setupState', 'v-' + dir.name)
107107
}
108108
dir.def = dir.def || resolveAsset(vm.$options, 'directives', dir.name, true)
109109
}

types/vnode.d.ts

+2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { Vue } from './vue'
2+
import { DirectiveFunction, DirectiveOptions } from './options'
23

34
export type ScopedSlot = (props: any) => ScopedSlotReturnValue
45
type ScopedSlotReturnValue =
@@ -86,4 +87,5 @@ export interface VNodeDirective {
8687
arg?: string
8788
oldArg?: string
8889
modifiers?: { [key: string]: boolean }
90+
def?: DirectiveFunction | DirectiveOptions
8991
}

0 commit comments

Comments
 (0)