From fd5cc562ac569a37fc662763de2716a1cb753530 Mon Sep 17 00:00:00 2001 From: Andrew Courtice Date: Wed, 1 Sep 2021 10:31:34 +1000 Subject: [PATCH] fix(utilities): unref value before testing type for cloning --- packages/utilities/src/object/clone.ts | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/packages/utilities/src/object/clone.ts b/packages/utilities/src/object/clone.ts index 9875c324..41c5701b 100644 --- a/packages/utilities/src/object/clone.ts +++ b/packages/utilities/src/object/clone.ts @@ -2,7 +2,7 @@ import getType from '../type/get-type'; import { unref, - UnwrapRef + UnwrapRef, } from 'vue'; import type { @@ -86,13 +86,14 @@ const CLONE_MAP = { } as Record unknown)>; export default function clone(value: TValue): UnwrapRef { - if (typeof value !== 'object' || value === null) { - return value as UnwrapRef; + const input = unref(value); + + if (typeof input !== 'object' || input === null) { + return input as UnwrapRef; } - const type = getType(value); + const type = getType(input); const cloner = CLONE_MAP[type] || CLONE_MAP.default; - const input = unref(value); return cloner(input) as UnwrapRef; } \ No newline at end of file