From: daiwei Date: Fri, 4 Jul 2025 14:39:18 +0000 (+0800) Subject: fix(reactivity): triggerRef work with proxy wrapped refs X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F13568%2Fhead;p=thirdparty%2Fvuejs%2Fcore.git fix(reactivity): triggerRef work with proxy wrapped refs --- 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) }