Skip to content

Commit 76ff6c9

Browse files
authored
fix: v-motion directive variants leaking (#173)
1 parent eddd121 commit 76ff6c9

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/directive/index.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { resolveVariants } from '../utils/directive'
88
import { variantToStyle } from '../utils/transform'
99
import { registerVisibilityHooks } from '../features/visibilityHooks'
1010

11-
export function directive<T extends string>(variants: MotionVariants<T> = {}): Directive<HTMLElement | SVGElement> {
11+
export function directive<T extends string>(variants?: MotionVariants<T>): Directive<HTMLElement | SVGElement> {
1212
const register = (el: HTMLElement | SVGElement, binding: DirectiveBinding, node: VNode<any, HTMLElement | SVGElement, Record<string, any>>) => {
1313
// Get instance key if possible (binding value or element key in case of v-for's)
1414
const key = (binding.value && typeof binding.value === 'string' ? binding.value : node.key) as string
@@ -17,7 +17,7 @@ export function directive<T extends string>(variants: MotionVariants<T> = {}): D
1717
if (key && motionState[key]) motionState[key].stop()
1818

1919
// Initialize variants with argument
20-
const variantsRef = ref(variants) as Ref<MotionVariants<T>>
20+
const variantsRef = ref(variants || {}) as Ref<MotionVariants<T>>
2121

2222
// Set variants from v-motion binding
2323
if (typeof binding.value === 'object') variantsRef.value = binding.value

0 commit comments

Comments
 (0)