Skip to content

Commit 6b69ff1

Browse files
committed
[build] 2.4.1
1 parent 91b7998 commit 6b69ff1

File tree

4 files changed

+100
-57
lines changed

4 files changed

+100
-57
lines changed

dist/vuex.common.js

Lines changed: 32 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* vuex v2.4.0
2+
* vuex v2.4.1
33
* (c) 2017 Evan You
44
* @license MIT
55
*/
@@ -107,7 +107,7 @@ var Module = function Module (rawModule, runtime) {
107107
this.state = (typeof rawState === 'function' ? rawState() : rawState) || {};
108108
};
109109

110-
var prototypeAccessors$1 = { namespaced: {} };
110+
var prototypeAccessors$1 = { namespaced: { configurable: true } };
111111

112112
prototypeAccessors$1.namespaced.get = function () {
113113
return !!this._rawModule.namespaced
@@ -275,6 +275,13 @@ var Store = function Store (options) {
275275
var this$1 = this;
276276
if ( options === void 0 ) options = {};
277277

278+
// Auto install if it is not done yet and `window` has `Vue`.
279+
// To allow users to avoid auto-installation in some cases,
280+
// this code should be placed here. See #731
281+
if (!Vue && typeof window !== 'undefined' && window.Vue) {
282+
install(window.Vue);
283+
}
284+
278285
if (process.env.NODE_ENV !== 'production') {
279286
assert(Vue, "must call Vue.use(Vuex) before creating a store instance.");
280287
assert(typeof Promise !== 'undefined', "vuex requires a Promise polyfill in this browser.");
@@ -331,7 +338,7 @@ var Store = function Store (options) {
331338
}
332339
};
333340

334-
var prototypeAccessors = { state: {} };
341+
var prototypeAccessors = { state: { configurable: true } };
335342

336343
prototypeAccessors.state.get = function () {
337344
return this._vm._data.$$state
@@ -729,7 +736,7 @@ function unifyObjectStyle (type, payload, options) {
729736
}
730737

731738
function install (_Vue) {
732-
if (Vue) {
739+
if (Vue && _Vue === Vue) {
733740
if (process.env.NODE_ENV !== 'production') {
734741
console.error(
735742
'[vuex] already installed. Vue.use(Vuex) should be called only once.'
@@ -741,11 +748,6 @@ function install (_Vue) {
741748
applyMixin(Vue);
742749
}
743750

744-
// auto install in dist mode
745-
if (typeof window !== 'undefined' && window.Vue) {
746-
install(window.Vue);
747-
}
748-
749751
var mapState = normalizeNamespace(function (namespace, states) {
750752
var res = {};
751753
normalizeMap(states).forEach(function (ref) {
@@ -779,15 +781,21 @@ var mapMutations = normalizeNamespace(function (namespace, mutations) {
779781
var key = ref.key;
780782
var val = ref.val;
781783

782-
val = namespace + val;
783784
res[key] = function mappedMutation () {
784785
var args = [], len = arguments.length;
785786
while ( len-- ) args[ len ] = arguments[ len ];
786787

787-
if (namespace && !getModuleByNamespace(this.$store, 'mapMutations', namespace)) {
788-
return
788+
var commit = this.$store.commit;
789+
if (namespace) {
790+
var module = getModuleByNamespace(this.$store, 'mapMutations', namespace);
791+
if (!module) {
792+
return
793+
}
794+
commit = module.context.commit;
789795
}
790-
return this.$store.commit.apply(this.$store, [val].concat(args))
796+
return typeof val === 'function'
797+
? val.apply(this, [commit].concat(args))
798+
: commit.apply(this.$store, [val].concat(args))
791799
};
792800
});
793801
return res
@@ -822,15 +830,21 @@ var mapActions = normalizeNamespace(function (namespace, actions) {
822830
var key = ref.key;
823831
var val = ref.val;
824832

825-
val = namespace + val;
826833
res[key] = function mappedAction () {
827834
var args = [], len = arguments.length;
828835
while ( len-- ) args[ len ] = arguments[ len ];
829836

830-
if (namespace && !getModuleByNamespace(this.$store, 'mapActions', namespace)) {
831-
return
837+
var dispatch = this.$store.dispatch;
838+
if (namespace) {
839+
var module = getModuleByNamespace(this.$store, 'mapActions', namespace);
840+
if (!module) {
841+
return
842+
}
843+
dispatch = module.context.dispatch;
832844
}
833-
return this.$store.dispatch.apply(this.$store, [val].concat(args))
845+
return typeof val === 'function'
846+
? val.apply(this, [dispatch].concat(args))
847+
: dispatch.apply(this.$store, [val].concat(args))
834848
};
835849
});
836850
return res
@@ -872,7 +886,7 @@ function getModuleByNamespace (store, helper, namespace) {
872886
var index = {
873887
Store: Store,
874888
install: install,
875-
version: '2.4.0',
889+
version: '2.4.1',
876890
mapState: mapState,
877891
mapMutations: mapMutations,
878892
mapGetters: mapGetters,

dist/vuex.esm.js

Lines changed: 34 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
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

110110
prototypeAccessors$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

334341
prototypeAccessors.state.get = function () {
335342
return this._vm._data.$$state
@@ -727,7 +734,7 @@ function unifyObjectStyle (type, payload, options) {
727734
}
728735

729736
function 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-
747749
var 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) {
870884
var 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;

dist/vuex.js

Lines changed: 32 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* vuex v2.4.0
2+
* vuex v2.4.1
33
* (c) 2017 Evan You
44
* @license MIT
55
*/
@@ -111,7 +111,7 @@ var Module = function Module (rawModule, runtime) {
111111
this.state = (typeof rawState === 'function' ? rawState() : rawState) || {};
112112
};
113113

114-
var prototypeAccessors$1 = { namespaced: {} };
114+
var prototypeAccessors$1 = { namespaced: { configurable: true } };
115115

116116
prototypeAccessors$1.namespaced.get = function () {
117117
return !!this._rawModule.namespaced
@@ -279,6 +279,13 @@ var Store = function Store (options) {
279279
var this$1 = this;
280280
if ( options === void 0 ) options = {};
281281

282+
// Auto install if it is not done yet and `window` has `Vue`.
283+
// To allow users to avoid auto-installation in some cases,
284+
// this code should be placed here. See #731
285+
if (!Vue && typeof window !== 'undefined' && window.Vue) {
286+
install(window.Vue);
287+
}
288+
282289
{
283290
assert(Vue, "must call Vue.use(Vuex) before creating a store instance.");
284291
assert(typeof Promise !== 'undefined', "vuex requires a Promise polyfill in this browser.");
@@ -335,7 +342,7 @@ var Store = function Store (options) {
335342
}
336343
};
337344

338-
var prototypeAccessors = { state: {} };
345+
var prototypeAccessors = { state: { configurable: true } };
339346

340347
prototypeAccessors.state.get = function () {
341348
return this._vm._data.$$state
@@ -733,7 +740,7 @@ function unifyObjectStyle (type, payload, options) {
733740
}
734741

735742
function install (_Vue) {
736-
if (Vue) {
743+
if (Vue && _Vue === Vue) {
737744
{
738745
console.error(
739746
'[vuex] already installed. Vue.use(Vuex) should be called only once.'
@@ -745,11 +752,6 @@ function install (_Vue) {
745752
applyMixin(Vue);
746753
}
747754

748-
// auto install in dist mode
749-
if (typeof window !== 'undefined' && window.Vue) {
750-
install(window.Vue);
751-
}
752-
753755
var mapState = normalizeNamespace(function (namespace, states) {
754756
var res = {};
755757
normalizeMap(states).forEach(function (ref) {
@@ -783,15 +785,21 @@ var mapMutations = normalizeNamespace(function (namespace, mutations) {
783785
var key = ref.key;
784786
var val = ref.val;
785787

786-
val = namespace + val;
787788
res[key] = function mappedMutation () {
788789
var args = [], len = arguments.length;
789790
while ( len-- ) args[ len ] = arguments[ len ];
790791

791-
if (namespace && !getModuleByNamespace(this.$store, 'mapMutations', namespace)) {
792-
return
792+
var commit = this.$store.commit;
793+
if (namespace) {
794+
var module = getModuleByNamespace(this.$store, 'mapMutations', namespace);
795+
if (!module) {
796+
return
797+
}
798+
commit = module.context.commit;
793799
}
794-
return this.$store.commit.apply(this.$store, [val].concat(args))
800+
return typeof val === 'function'
801+
? val.apply(this, [commit].concat(args))
802+
: commit.apply(this.$store, [val].concat(args))
795803
};
796804
});
797805
return res
@@ -826,15 +834,21 @@ var mapActions = normalizeNamespace(function (namespace, actions) {
826834
var key = ref.key;
827835
var val = ref.val;
828836

829-
val = namespace + val;
830837
res[key] = function mappedAction () {
831838
var args = [], len = arguments.length;
832839
while ( len-- ) args[ len ] = arguments[ len ];
833840

834-
if (namespace && !getModuleByNamespace(this.$store, 'mapActions', namespace)) {
835-
return
841+
var dispatch = this.$store.dispatch;
842+
if (namespace) {
843+
var module = getModuleByNamespace(this.$store, 'mapActions', namespace);
844+
if (!module) {
845+
return
846+
}
847+
dispatch = module.context.dispatch;
836848
}
837-
return this.$store.dispatch.apply(this.$store, [val].concat(args))
849+
return typeof val === 'function'
850+
? val.apply(this, [dispatch].concat(args))
851+
: dispatch.apply(this.$store, [val].concat(args))
838852
};
839853
});
840854
return res
@@ -876,7 +890,7 @@ function getModuleByNamespace (store, helper, namespace) {
876890
var index = {
877891
Store: Store,
878892
install: install,
879-
version: '2.4.0',
893+
version: '2.4.1',
880894
mapState: mapState,
881895
mapMutations: mapMutations,
882896
mapGetters: mapGetters,

0 commit comments

Comments
 (0)