Skip to content

Commit 59345c1

Browse files
fix(cloneDeepUnref): properly unwrap ref with undefined value (#126)
1 parent 141cc84 commit 59345c1

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

src/vue/__tests__/utils.test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,5 +260,9 @@ describe("utils", () => {
260260
d: { e: "e" },
261261
});
262262
});
263+
264+
test("should unref undefined", () => {
265+
expect(cloneDeepUnref(ref(undefined))).toBe(undefined);
266+
});
263267
});
264268
});

src/vue/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ export function cloneDeep<T>(
125125
): T {
126126
if (customizer) {
127127
const result = customizer(value);
128-
if (result !== undefined) {
128+
if (result !== undefined || isRef(value)) {
129129
return result as typeof value;
130130
}
131131
}

0 commit comments

Comments
 (0)