Skip to content

Commit 4cb7301

Browse files
committed
object style commit should record mutation in the same format
1 parent 6b9295a commit 4cb7301

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

src/index.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,14 +62,12 @@ class Store {
6262

6363
commit (type, payload, options) {
6464
// check object-style commit
65-
let mutation
6665
if (isObject(type) && type.type) {
6766
options = payload
68-
payload = mutation = type
67+
payload = type
6968
type = type.type
70-
} else {
71-
mutation = { type, payload }
7269
}
70+
const mutation = { type, payload }
7371
const entry = this._mutations[type]
7472
if (!entry) {
7573
console.error(`[vuex] unknown mutation type: ${type}`)

test/unit/test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -674,8 +674,8 @@ describe('Vuex', () => {
674674
expect(mutations.length).toBe(2)
675675
expect(mutations[0].type).toBe(TEST)
676676
expect(mutations[1].type).toBe(TEST)
677-
expect(mutations[0].payload.n).toBe(1) // normal dispatch
678-
expect(mutations[1].n).toBe(2) // object dispatch
677+
expect(mutations[0].payload.n).toBe(1) // normal commit
678+
expect(mutations[1].payload.n).toBe(2) // object commit
679679
})
680680

681681
it('strict mode: warn mutations outside of handlers', function () {

0 commit comments

Comments
 (0)