Skip to content

Commit 19ae372

Browse files
fix(reactivity): avoid unwrapping .value when the proxy is a direct wrapper of Ref (#13569)
1 parent be178f8 commit 19ae372

File tree

3 files changed

+7
-8
lines changed

3 files changed

+7
-8
lines changed

packages/reactivity/__tests__/readonly.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -523,7 +523,7 @@ describe('reactivity/readonly', () => {
523523
})
524524
})
525525

526-
test.todo('should be able to trigger with triggerRef', () => {
526+
test('should be able to trigger with triggerRef', () => {
527527
const r = shallowRef({ a: 1 })
528528
const ror = readonly(r)
529529
let dummy

packages/reactivity/src/baseHandlers.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,15 +96,20 @@ class BaseReactiveHandler implements ProxyHandler<Target> {
9696
}
9797
}
9898

99+
const wasRef = isRef(target)
99100
const res = Reflect.get(
100101
target,
101102
key,
102103
// if this is a proxy wrapping a ref, return methods using the raw ref
103104
// as receiver so that we don't have to call `toRaw` on the ref in all
104105
// its class methods
105-
isRef(target) ? target : receiver,
106+
wasRef ? target : receiver,
106107
)
107108

109+
if (wasRef && key !== 'value') {
110+
return res
111+
}
112+
108113
if (isSymbol(key) ? builtInSymbols.has(key) : isNonTrackableKeys(key)) {
109114
return res
110115
}

packages/reactivity/src/dep.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,6 @@ class Dep implements Dependency {
1515
_subs: Link | undefined = undefined
1616
subsTail: Link | undefined = undefined
1717

18-
/**
19-
* @internal
20-
*/
21-
readonly __v_skip = true
22-
// TODO isolatedDeclarations ReactiveFlags.SKIP
23-
2418
constructor(
2519
private map: KeyToDepMap,
2620
private key: unknown,

0 commit comments

Comments
 (0)