11/**
2- * vuex v2.4.0
2+ * vuex v2.4.1
33 * (c) 2017 Evan You
44 * @license MIT
55 */
@@ -105,7 +105,7 @@ var Module = function Module (rawModule, runtime) {
105105 this . state = ( typeof rawState === 'function' ? rawState ( ) : rawState ) || { } ;
106106} ;
107107
108- var prototypeAccessors$1 = { namespaced : { } } ;
108+ var prototypeAccessors$1 = { namespaced : { configurable : true } } ;
109109
110110prototypeAccessors$1 . namespaced . get = function ( ) {
111111 return ! ! this . _rawModule . namespaced
@@ -273,6 +273,13 @@ var Store = function Store (options) {
273273 var this$1 = this ;
274274 if ( options === void 0 ) options = { } ;
275275
276+ // Auto install if it is not done yet and `window` has `Vue`.
277+ // To allow users to avoid auto-installation in some cases,
278+ // this code should be placed here. See #731
279+ if ( ! Vue && typeof window !== 'undefined' && window . Vue ) {
280+ install ( window . Vue ) ;
281+ }
282+
276283 if ( process . env . NODE_ENV !== 'production' ) {
277284 assert ( Vue , "must call Vue.use(Vuex) before creating a store instance." ) ;
278285 assert ( typeof Promise !== 'undefined' , "vuex requires a Promise polyfill in this browser." ) ;
@@ -329,7 +336,7 @@ var Store = function Store (options) {
329336 }
330337} ;
331338
332- var prototypeAccessors = { state : { } } ;
339+ var prototypeAccessors = { state : { configurable : true } } ;
333340
334341prototypeAccessors . state . get = function ( ) {
335342 return this . _vm . _data . $$state
@@ -727,7 +734,7 @@ function unifyObjectStyle (type, payload, options) {
727734}
728735
729736function install ( _Vue ) {
730- if ( Vue ) {
737+ if ( Vue && _Vue === Vue ) {
731738 if ( process . env . NODE_ENV !== 'production' ) {
732739 console . error (
733740 '[vuex] already installed. Vue.use(Vuex) should be called only once.'
@@ -739,11 +746,6 @@ function install (_Vue) {
739746 applyMixin ( Vue ) ;
740747}
741748
742- // auto install in dist mode
743- if ( typeof window !== 'undefined' && window . Vue ) {
744- install ( window . Vue ) ;
745- }
746-
747749var mapState = normalizeNamespace ( function ( namespace , states ) {
748750 var res = { } ;
749751 normalizeMap ( states ) . forEach ( function ( ref ) {
@@ -777,15 +779,21 @@ var mapMutations = normalizeNamespace(function (namespace, mutations) {
777779 var key = ref . key ;
778780 var val = ref . val ;
779781
780- val = namespace + val ;
781782 res [ key ] = function mappedMutation ( ) {
782783 var args = [ ] , len = arguments . length ;
783784 while ( len -- ) args [ len ] = arguments [ len ] ;
784785
785- if ( namespace && ! getModuleByNamespace ( this . $store , 'mapMutations' , namespace ) ) {
786- return
786+ var commit = this . $store . commit ;
787+ if ( namespace ) {
788+ var module = getModuleByNamespace ( this . $store , 'mapMutations' , namespace ) ;
789+ if ( ! module ) {
790+ return
791+ }
792+ commit = module . context . commit ;
787793 }
788- return this . $store . commit . apply ( this . $store , [ val ] . concat ( args ) )
794+ return typeof val === 'function'
795+ ? val . apply ( this , [ commit ] . concat ( args ) )
796+ : commit . apply ( this . $store , [ val ] . concat ( args ) )
789797 } ;
790798 } ) ;
791799 return res
@@ -820,15 +828,21 @@ var mapActions = normalizeNamespace(function (namespace, actions) {
820828 var key = ref . key ;
821829 var val = ref . val ;
822830
823- val = namespace + val ;
824831 res [ key ] = function mappedAction ( ) {
825832 var args = [ ] , len = arguments . length ;
826833 while ( len -- ) args [ len ] = arguments [ len ] ;
827834
828- if ( namespace && ! getModuleByNamespace ( this . $store , 'mapActions' , namespace ) ) {
829- return
835+ var dispatch = this . $store . dispatch ;
836+ if ( namespace ) {
837+ var module = getModuleByNamespace ( this . $store , 'mapActions' , namespace ) ;
838+ if ( ! module ) {
839+ return
840+ }
841+ dispatch = module . context . dispatch ;
830842 }
831- return this . $store . dispatch . apply ( this . $store , [ val ] . concat ( args ) )
843+ return typeof val === 'function'
844+ ? val . apply ( this , [ dispatch ] . concat ( args ) )
845+ : dispatch . apply ( this . $store , [ val ] . concat ( args ) )
832846 } ;
833847 } ) ;
834848 return res
@@ -870,12 +884,13 @@ function getModuleByNamespace (store, helper, namespace) {
870884var index_esm = {
871885 Store : Store ,
872886 install : install ,
873- version : '2.4.0 ' ,
887+ version : '2.4.1 ' ,
874888 mapState : mapState ,
875889 mapMutations : mapMutations ,
876890 mapGetters : mapGetters ,
877891 mapActions : mapActions ,
878892 createNamespacedHelpers : createNamespacedHelpers
879893} ;
880894
881- export { Store , mapState , mapMutations , mapGetters , mapActions , createNamespacedHelpers } ; export default index_esm ;
895+ export { Store , install , mapState , mapMutations , mapGetters , mapActions , createNamespacedHelpers } ;
896+ export default index_esm ;
0 commit comments