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 {
6363 }
6464
6565 module ( path , module , hot ) {
66+ this . _committing = true
6667 if ( typeof path === 'string' ) path = [ path ]
6768 assert ( Array . isArray ( path ) , `module path must be a string or an Array.` )
6869
@@ -99,6 +100,7 @@ class Store {
99100 this . module ( path . concat ( key ) , modules [ key ] , hot )
100101 } )
101102 }
103+ this . _committing = false
102104 }
103105
104106 mutation ( type , handler , path = [ ] ) {
Original file line number Diff line number Diff line change @@ -191,6 +191,21 @@ describe('Vuex', () => {
191191 expect ( store . getters . hasAny ) . to . equal ( true )
192192 } )
193193
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+
194209 it ( 'store injection' , ( ) => {
195210 const store = new Vuex . Store ( )
196211 const vm = new Vue ( {
You can’t perform that action at this time.
0 commit comments