Skip to content

Commit 247443b

Browse files
author
Guillaume Chau
committed
fix(vuex): vuex 1.0 support
1 parent c51eab8 commit 247443b

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

src/backend/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,10 +125,10 @@ function connect (Vue) {
125125

126126
// vuex
127127
if (hook.store) {
128-
initVuexBackend(hook, bridge)
128+
initVuexBackend(hook, bridge, isLegacy)
129129
} else {
130130
hook.once('vuex:init', store => {
131-
initVuexBackend(hook, bridge)
131+
initVuexBackend(hook, bridge, isLegacy)
132132
})
133133
}
134134

src/backend/vuex.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import SharedData from 'src/shared-data'
33
import { set } from '../util'
44
import Vue from 'vue'
55

6-
export function initVuexBackend (hook, bridge) {
6+
export function initVuexBackend (hook, bridge, isLegacy) {
77
const store = hook.store
88

99
let originalVm = store._vm
@@ -147,7 +147,16 @@ export function initVuexBackend (hook, bridge) {
147147
for (let i = snapshot.index + 1; i <= index; i++) {
148148
const mutation = mutations[i]
149149
if (mutation.handlers) {
150-
mutation.handlers.forEach(handler => handler(mutation.payload))
150+
if (Array.isArray(mutation.handlers)) {
151+
mutation.handlers.forEach(handler => handler(mutation.payload))
152+
} else {
153+
if (isLegacy) {
154+
// Vuex 1
155+
mutation.handlers(store.state, mutation.payload)
156+
} else {
157+
mutation.handlers(mutation.payload)
158+
}
159+
}
151160
}
152161

153162
if (i !== index && i % SharedData.cacheVuexSnapshotsEvery === 0) {

0 commit comments

Comments
 (0)