From 852ac43ea4813ecaeb1e5106c4a29c74e57c2fd7 Mon Sep 17 00:00:00 2001 From: katashin Date: Sat, 2 Sep 2017 00:44:22 +0900 Subject: [PATCH] fix: move auto installation code into the store constructor (#914) --- src/store.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/store.js b/src/store.js index fce8d60ae..0a540e809 100644 --- a/src/store.js +++ b/src/store.js @@ -7,6 +7,13 @@ let Vue // bind on install export class Store { constructor (options = {}) { + // Auto install if it is not done yet and `window` has `Vue`. + // To allow users to avoid auto-installation in some cases, + // this code should be placed here. See #731 + if (!Vue && typeof window !== 'undefined' && window.Vue) { + install(window.Vue) + } + if (process.env.NODE_ENV !== 'production') { assert(Vue, `must call Vue.use(Vuex) before creating a store instance.`) assert(typeof Promise !== 'undefined', `vuex requires a Promise polyfill in this browser.`) @@ -463,8 +470,3 @@ export function install (_Vue) { Vue = _Vue applyMixin(Vue) } - -// auto install in dist mode -if (typeof window !== 'undefined' && window.Vue) { - install(window.Vue) -}