@@ -20,7 +20,10 @@ export class StateEditor {
20
20
const markRef = false
21
21
while ( sections . length > 1 ) {
22
22
const section = sections . shift ( ) !
23
- object = object [ section ] as Recordable
23
+ if ( object instanceof Map )
24
+ object = object . get ( section ) as Recordable
25
+ else
26
+ object = object [ section ] as Recordable
24
27
if ( this . refEditor . isRef ( object ) )
25
28
object = this . refEditor . get ( object )
26
29
}
@@ -42,7 +45,10 @@ export class StateEditor {
42
45
get ( object : Recordable , path : PropPath ) {
43
46
const sections = Array . isArray ( path ) ? path : path . split ( '.' )
44
47
for ( let i = 0 ; i < sections . length ; i ++ ) {
45
- object = object [ sections [ i ] ] as Recordable
48
+ if ( object instanceof Map )
49
+ object = object . get ( sections [ i ] ) as Recordable
50
+ else
51
+ object = object [ sections [ i ] ] as Recordable
46
52
if ( this . refEditor . isRef ( object ) )
47
53
object = this . refEditor . get ( object )
48
54
if ( ! object )
@@ -70,17 +76,18 @@ export class StateEditor {
70
76
if ( state . remove || state . newKey ) {
71
77
if ( Array . isArray ( object ) )
72
78
object . splice ( field as number , 1 )
73
- else if ( toRaw ( object ) instanceof Map && typeof value === 'object' && value && 'key' in value )
74
- object . delete ( value . key )
79
+ else if ( toRaw ( object ) instanceof Map )
80
+ object . delete ( field )
75
81
else if ( toRaw ( object ) instanceof Set )
76
82
object . delete ( value )
77
- else
78
- Reflect . deleteProperty ( object , field )
83
+ else Reflect . deleteProperty ( object , field )
79
84
}
80
85
if ( ! state . remove ) {
81
86
const target = object [ state . newKey || field ]
82
87
if ( this . refEditor . isRef ( target ) )
83
88
this . refEditor . set ( target , value )
89
+ else if ( toRaw ( object ) instanceof Map )
90
+ object . set ( state . newKey || field , value )
84
91
else
85
92
object [ state . newKey || field ] = value
86
93
}
0 commit comments