@@ -26,16 +26,22 @@ function get(
2626 wrap : typeof toReactive | typeof toReadonly
2727) {
2828 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+ }
3237}
3338
3439function has ( this : CollectionTypes , key : unknown ) : boolean {
3540 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 )
3945}
4046
4147function size ( target : IterableCollections ) {
@@ -73,13 +79,16 @@ function set(this: MapTypes, key: unknown, value: unknown) {
7379}
7480
7581function deleteEntry ( this : CollectionTypes , key : unknown ) {
76- key = toRaw ( key )
7782 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
8190 // forward the operation before queueing reactions
82- const result = proto . delete . call ( target , key )
91+ const result = del . call ( target , key )
8392 if ( hadKey ) {
8493 trigger ( target , TriggerOpTypes . DELETE , key , undefined , oldValue )
8594 }
@@ -177,7 +186,7 @@ const mutableInstrumentations: Record<string, Function> = {
177186 return get ( this , key , toReactive )
178187 } ,
179188 get size ( ) {
180- return size ( this as unknown as IterableCollections )
189+ return size ( ( this as unknown ) as IterableCollections )
181190 } ,
182191 has,
183192 add,
0 commit comments