@@ -140,9 +140,11 @@ export function initVuexBackend (hook, bridge, isLegacy) {
140
140
function addMutation ( type , payload , options = { } ) {
141
141
const index = mutations . length
142
142
143
+ const payloadData = stringify ( payload )
144
+
143
145
mutations . push ( {
144
146
type,
145
- payload,
147
+ payload : payloadData ,
146
148
index,
147
149
handlers : store . _mutations [ type ] ,
148
150
registeredModules : Object . keys ( registeredModules ) ,
@@ -152,7 +154,7 @@ export function initVuexBackend (hook, bridge, isLegacy) {
152
154
bridge . send ( 'vuex:mutation' , {
153
155
mutation : {
154
156
type : type ,
155
- payload : stringify ( payload ) ,
157
+ payload : payloadData ,
156
158
index
157
159
} ,
158
160
timestamp : Date . now ( )
@@ -294,15 +296,20 @@ export function initVuexBackend (hook, bridge, isLegacy) {
294
296
if ( ! isProd ) console . log ( 'replay unregister module' , path )
295
297
} else if ( mutation . handlers ) {
296
298
store . _committing = true
297
- if ( Array . isArray ( mutation . handlers ) ) {
298
- mutation . handlers . forEach ( handler => handler ( mutation . payload ) )
299
- } else {
300
- if ( isLegacy ) {
301
- // Vuex 1
302
- mutation . handlers ( store . state , mutation . payload )
299
+ try {
300
+ const payload = parse ( mutation . payload , true )
301
+ if ( Array . isArray ( mutation . handlers ) ) {
302
+ mutation . handlers . forEach ( handler => handler ( payload ) )
303
303
} else {
304
- mutation . handlers ( mutation . payload )
304
+ if ( isLegacy ) {
305
+ // Vuex 1
306
+ mutation . handlers ( store . state , payload )
307
+ } else {
308
+ mutation . handlers ( payload )
309
+ }
305
310
}
311
+ } catch ( e ) {
312
+ throw e
306
313
}
307
314
store . _committing = false
308
315
}
0 commit comments