]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
fix(reactivity): triggerRef work with proxy wrapped refs edison/fix/triggerRef 13568/head
authordaiwei <daiwei521@126.com>
Fri, 4 Jul 2025 14:39:18 +0000 (22:39 +0800)
committerdaiwei <daiwei521@126.com>
Fri, 4 Jul 2025 14:39:18 +0000 (22:39 +0800)
packages/reactivity/__tests__/readonly.spec.ts
packages/reactivity/src/ref.ts

index 5c70b6082f1e32ea7e2a36a8acde0859cd2b7e83..b035779f85aba3736b6cea0de488903b57a3e34b 100644 (file)
@@ -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
index 851683557bee184387fa85181419322f7b828396..30c67e5312f8d6c17504390b6f6148c91fee3c18 100644 (file)
@@ -187,8 +187,8 @@ class RefImpl<T = any> 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)
   }