From d704ffacddf207980eba95823f74bdc4f13e419a Mon Sep 17 00:00:00 2001 From: daiwei Date: Fri, 4 Jul 2025 22:39:18 +0800 Subject: [PATCH] fix(reactivity): triggerRef work with proxy wrapped refs --- packages/reactivity/__tests__/readonly.spec.ts | 2 +- packages/reactivity/src/ref.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/reactivity/__tests__/readonly.spec.ts b/packages/reactivity/__tests__/readonly.spec.ts index 5c70b6082f..b035779f85 100644 --- a/packages/reactivity/__tests__/readonly.spec.ts +++ b/packages/reactivity/__tests__/readonly.spec.ts @@ -523,7 +523,7 @@ describe('reactivity/readonly', () => { }) }) -test.todo('should be able to trigger with triggerRef', () => { +test('should be able to trigger with triggerRef', () => { const r = shallowRef({ a: 1 }) const ror = readonly(r) let dummy diff --git a/packages/reactivity/src/ref.ts b/packages/reactivity/src/ref.ts index 851683557b..30c67e5312 100644 --- a/packages/reactivity/src/ref.ts +++ b/packages/reactivity/src/ref.ts @@ -187,8 +187,8 @@ class RefImpl implements Dependency { * @see {@link https://vuejs.org/api/reactivity-advanced.html#triggerref} */ export function triggerRef(ref: Ref): void { - // ref may be an instance of ObjectRefImpl - const dep = (ref as unknown as RefImpl).dep + const rawRef = isProxy(ref) ? toRaw(ref) : ref + const dep = (rawRef as unknown as RefImpl).dep if (dep !== undefined && dep.subs !== undefined) { propagate(dep.subs) } -- 2.39.5