File tree Expand file tree Collapse file tree 2 files changed +17
-0
lines changed Expand file tree Collapse file tree 2 files changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -63,6 +63,7 @@ class Store {
63
63
}
64
64
65
65
module ( path , module , hot ) {
66
+ this . _committing = true
66
67
if ( typeof path === 'string' ) path = [ path ]
67
68
assert ( Array . isArray ( path ) , `module path must be a string or an Array.` )
68
69
@@ -99,6 +100,7 @@ class Store {
99
100
this . module ( path . concat ( key ) , modules [ key ] , hot )
100
101
} )
101
102
}
103
+ this . _committing = false
102
104
}
103
105
104
106
mutation ( type , handler , path = [ ] ) {
Original file line number Diff line number Diff line change @@ -191,6 +191,21 @@ describe('Vuex', () => {
191
191
expect ( store . getters . hasAny ) . to . equal ( true )
192
192
} )
193
193
194
+ it ( 'dynamic module registration' , ( ) => {
195
+ const store = new Vuex . Store ( {
196
+ strict : true
197
+ } )
198
+ expect ( ( ) => {
199
+ store . module ( 'hi' , {
200
+ state : { a : 1 } ,
201
+ mutations : { inc : state => state . a ++ }
202
+ } )
203
+ } ) . not . to . throw ( )
204
+ expect ( store . state . hi . a ) . to . equal ( 1 )
205
+ store . commit ( 'inc' )
206
+ expect ( store . state . hi . a ) . to . equal ( 2 )
207
+ } )
208
+
194
209
it ( 'store injection' , ( ) => {
195
210
const store = new Vuex . Store ( )
196
211
const vm = new Vue ( {
You can’t perform that action at this time.
0 commit comments