@@ -26,16 +26,22 @@ function get(
26
26
wrap : typeof toReactive | typeof toReadonly
27
27
) {
28
28
target = toRaw ( target )
29
- key = toRaw ( key )
30
- track ( target , TrackOpTypes . GET , key )
31
- return wrap ( getProto ( target ) . get . call ( target , key ) )
29
+ const rawKey = toRaw ( key )
30
+ track ( target , TrackOpTypes . GET , rawKey )
31
+ const { has, get } = getProto ( target )
32
+ if ( has . call ( target , key ) ) {
33
+ return wrap ( get . call ( target , key ) )
34
+ } else if ( has . call ( target , rawKey ) ) {
35
+ return wrap ( get . call ( target , rawKey ) )
36
+ }
32
37
}
33
38
34
39
function has ( this : CollectionTypes , key : unknown ) : boolean {
35
40
const target = toRaw ( this )
36
- key = toRaw ( key )
37
- track ( target , TrackOpTypes . HAS , key )
38
- return getProto ( target ) . has . call ( target , key )
41
+ const rawKey = toRaw ( key )
42
+ track ( target , TrackOpTypes . HAS , rawKey )
43
+ const has = getProto ( target ) . has
44
+ return has . call ( target , key ) || has . call ( target , rawKey )
39
45
}
40
46
41
47
function size ( target : IterableCollections ) {
@@ -73,13 +79,16 @@ function set(this: MapTypes, key: unknown, value: unknown) {
73
79
}
74
80
75
81
function deleteEntry ( this : CollectionTypes , key : unknown ) {
76
- key = toRaw ( key )
77
82
const target = toRaw ( this )
78
- const proto = getProto ( target )
79
- const hadKey = proto . has . call ( target , key )
80
- const oldValue = proto . get ? proto . get . call ( target , key ) : undefined
83
+ const { has, get, delete : del } = getProto ( target )
84
+ let hadKey = has . call ( target , key )
85
+ if ( ! hadKey ) {
86
+ key = toRaw ( key )
87
+ hadKey = has . call ( target , key )
88
+ }
89
+ const oldValue = get ? get . call ( target , key ) : undefined
81
90
// forward the operation before queueing reactions
82
- const result = proto . delete . call ( target , key )
91
+ const result = del . call ( target , key )
83
92
if ( hadKey ) {
84
93
trigger ( target , TriggerOpTypes . DELETE , key , undefined , oldValue )
85
94
}
@@ -177,7 +186,7 @@ const mutableInstrumentations: Record<string, Function> = {
177
186
return get ( this , key , toReactive )
178
187
} ,
179
188
get size ( ) {
180
- return size ( this as unknown as IterableCollections )
189
+ return size ( ( this as unknown ) as IterableCollections )
181
190
} ,
182
191
has,
183
192
add,
0 commit comments