File tree Expand file tree Collapse file tree 2 files changed +14
-2
lines changed Expand file tree Collapse file tree 2 files changed +14
-2
lines changed Original file line number Diff line number Diff line change 1
1
import { RefKey } from '../utils/symbols'
2
- import { proxy , isPlainObject , warn } from '../utils'
2
+ import { proxy , isPlainObject , warn , def } from '../utils'
3
3
import { reactive , isReactive , shallowReactive } from './reactive'
4
4
import { readonlySet } from '../utils/sets'
5
5
@@ -193,6 +193,8 @@ export function proxyRefs<T extends object>(
193
193
}
194
194
const value : Record < string , any > = reactive ( { [ RefKey ] : objectWithRefs } )
195
195
196
+ def ( value , RefKey , value [ RefKey ] , false )
197
+
196
198
for ( const key of Object . keys ( objectWithRefs ) ) {
197
199
proxy ( value , key , {
198
200
get ( ) {
Original file line number Diff line number Diff line change @@ -13,7 +13,9 @@ import {
13
13
isReactive ,
14
14
shallowRef ,
15
15
proxyRefs ,
16
+ ShallowUnwrapRef ,
16
17
} from '../../../src'
18
+ import { RefKey } from '../../../src/utils/symbols'
17
19
18
20
describe ( 'reactivity/ref' , ( ) => {
19
21
it ( 'should hold a value' , ( ) => {
@@ -379,15 +381,23 @@ describe('reactivity/ref', () => {
379
381
y : ref ( 'foo' ) ,
380
382
} ,
381
383
}
382
- const p = proxyRefs ( a )
384
+ const reactiveA = {
385
+ [ RefKey ] : a ,
386
+ ...a ,
387
+ }
388
+ const p = proxyRefs ( a ) as ShallowUnwrapRef < typeof reactiveA >
383
389
expect ( p . x ) . toBe ( 1 )
384
390
expect ( p . obj . y ) . toBe ( 'foo' )
391
+ expect ( p [ RefKey ] ) . toBe ( a )
392
+ expect ( Object . keys ( p ) ) . toStrictEqual ( [ 'x' , 'obj' ] )
385
393
386
394
// @ts -expect-error
387
395
p . obj . y = 'bar'
388
396
p . x = 2
389
397
expect ( a . x ) . toBe ( 2 )
390
398
expect ( a . obj . y ) . toBe ( 'bar' )
399
+ expect ( p [ RefKey ] ) . toBe ( a )
400
+ expect ( Object . keys ( p ) ) . toStrictEqual ( [ 'x' , 'obj' ] )
391
401
392
402
const r = reactive ( { k : 'v' } )
393
403
const s = proxyRefs ( r )
You can’t perform that action at this time.
0 commit comments