]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
fix(reactivity): avoid unwrapping `.value` when the proxy is a direct wrapper of...
authorJohnson Chu <johnsoncodehk@gmail.com>
Mon, 7 Jul 2025 00:05:18 +0000 (08:05 +0800)
committerGitHub <noreply@github.com>
Mon, 7 Jul 2025 00:05:18 +0000 (08:05 +0800)
packages/reactivity/__tests__/readonly.spec.ts
packages/reactivity/src/baseHandlers.ts
packages/reactivity/src/dep.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 faec3012f402b5a611964497e5e355b2646c00c9..3b2dcfdec90cd989c3fa3e984b37cd6d566b870a 100644 (file)
@@ -96,15 +96,20 @@ class BaseReactiveHandler implements ProxyHandler<Target> {
       }
     }
 
+    const wasRef = isRef(target)
     const res = Reflect.get(
       target,
       key,
       // if this is a proxy wrapping a ref, return methods using the raw ref
       // as receiver so that we don't have to call `toRaw` on the ref in all
       // its class methods
-      isRef(target) ? target : receiver,
+      wasRef ? target : receiver,
     )
 
+    if (wasRef && key !== 'value') {
+      return res
+    }
+
     if (isSymbol(key) ? builtInSymbols.has(key) : isNonTrackableKeys(key)) {
       return res
     }
index 3fd81514b6f263aa349156409746ca0aae454aa0..184964c17b8847b9a18af0c03f83056407c4230b 100644 (file)
@@ -15,12 +15,6 @@ class Dep implements Dependency {
   _subs: Link | undefined = undefined
   subsTail: Link | undefined = undefined
 
-  /**
-   * @internal
-   */
-  readonly __v_skip = true
-  // TODO isolatedDeclarations ReactiveFlags.SKIP
-
   constructor(
     private map: KeyToDepMap,
     private key: unknown,