Skip to content

Commit d5774ac

Browse files
authored
fix: support directives kebab-case(#108) (#141)
1 parent ab5ca2f commit d5774ac

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/utils/directive.ts

+6-4
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { isObject } from '@vueuse/core'
22
import type { Ref, VNode } from 'vue'
33
import type { MotionVariants } from '../types'
44

5-
const directivePropsKeys = ['initial', 'enter', 'leave', 'visible', 'visible-once', 'hovered', 'tapped', 'focused', 'delay']
5+
const directivePropsKeys = ['initial', 'enter', 'leave', 'visible', 'visible-once', 'visibleOnce', 'hovered', 'tapped', 'focused', 'delay']
66

77
export function resolveVariants<T extends string>(node: VNode<any, HTMLElement | SVGElement, Record<string, any>>, variantsRef: Ref<MotionVariants<T>>) {
88
// This is done to achieve compat with Vue 2 & 3
@@ -62,10 +62,12 @@ export function resolveVariants<T extends string>(node: VNode<any, HTMLElement |
6262
return
6363
}
6464

65-
if (key === 'visible-once') key = 'visibleOnce'
66-
6765
// @ts-expect-error - Fix errors later for typescript 5
68-
if (target && target[key] && isObject(target[key])) variantsRef.value[key] = target[key]
66+
if (target && target[key] && isObject(target[key])) {
67+
const prop = target[key]
68+
if (key === 'visible-once') key = 'visibleOnce'
69+
variantsRef.value[key as keyof MotionVariants<T>] = prop
70+
}
6971
})
7072
}
7173
}

0 commit comments

Comments
 (0)