Skip to content

fix(reactivity): avoid unwrapping .value when the proxy is a direct wrapper of Ref #13569

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/reactivity/__tests__/readonly.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 6 additions & 1 deletion packages/reactivity/src/baseHandlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
6 changes: 0 additions & 6 deletions packages/reactivity/src/dep.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down