@@ -32,17 +32,20 @@ function get(
32
32
key : unknown ,
33
33
wrap : typeof toReactive | typeof toReadonly | typeof toShallow
34
34
) {
35
- target = toRaw ( target )
35
+ // #1772: readonly(reactive(Map)) should return readonly + reactive version
36
+ // of the value
37
+ target = ( target as any ) [ ReactiveFlags . RAW ]
38
+ const rawTarget = toRaw ( target )
36
39
const rawKey = toRaw ( key )
37
40
if ( key !== rawKey ) {
38
- track ( target , TrackOpTypes . GET , key )
41
+ track ( rawTarget , TrackOpTypes . GET , key )
39
42
}
40
- track ( target , TrackOpTypes . GET , rawKey )
41
- const { has, get } = getProto ( target )
42
- if ( has . call ( target , key ) ) {
43
- return wrap ( get . call ( target , key ) )
44
- } else if ( has . call ( target , rawKey ) ) {
45
- return wrap ( get . call ( target , rawKey ) )
43
+ track ( rawTarget , TrackOpTypes . GET , rawKey )
44
+ const { has } = getProto ( rawTarget )
45
+ if ( has . call ( rawTarget , key ) ) {
46
+ return wrap ( target . get ( key ) )
47
+ } else if ( has . call ( rawTarget , rawKey ) ) {
48
+ return wrap ( target . get ( rawKey ) )
46
49
}
47
50
}
48
51
@@ -176,15 +179,16 @@ function createIterableMethod(
176
179
this : IterableCollections ,
177
180
...args : unknown [ ]
178
181
) : Iterable & Iterator {
179
- const target = toRaw ( this )
180
- const isMap = target instanceof Map
182
+ const target = ( this as any ) [ ReactiveFlags . RAW ]
183
+ const rawTarget = toRaw ( this )
184
+ const isMap = rawTarget instanceof Map
181
185
const isPair = method === 'entries' || ( method === Symbol . iterator && isMap )
182
186
const isKeyOnly = method === 'keys' && isMap
183
- const innerIterator = getProto ( target ) [ method ] . apply ( target , args )
187
+ const innerIterator = target [ method ] ( ... args )
184
188
const wrap = isReadonly ? toReadonly : shallow ? toShallow : toReactive
185
189
! isReadonly &&
186
190
track (
187
- target ,
191
+ rawTarget ,
188
192
TrackOpTypes . ITERATE ,
189
193
isKeyOnly ? MAP_KEY_ITERATE_KEY : ITERATE_KEY
190
194
)
0 commit comments