Skip to content

fix: use toRaw when cloning proxy object #221

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

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/directive/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { Directive, DirectiveBinding, Ref, VNode } from 'vue'
import defu from 'defu'
import { ref, unref } from 'vue'
import { ref, toRaw, unref } from 'vue'
import { motionState } from '../features/state'
import type { MotionInstance, MotionVariants } from '../types'
import { useMotion } from '../useMotion'
Expand All @@ -21,7 +21,7 @@ export function directive<T extends string>(
motionState[key].stop()

// We deep copy presets to prevent global mutation
const variantsObject = isPreset ? structuredClone(variants || {}) : variants || {}
const variantsObject = isPreset ? structuredClone(toRaw(variants) || {}) : variants || {}

// Initialize variants with argument
const variantsRef = ref(variantsObject) as Ref<MotionVariants<T>>
Expand Down
Loading