Skip to content

Commit

Permalink
fix: move auto installation code into the store constructor (#914)
Browse files Browse the repository at this point in the history
  • Loading branch information
ktsn authored and yyx990803 committed Sep 1, 2017
1 parent be15f32 commit 852ac43
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.`)
Expand Down Expand Up @@ -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)
}

2 comments on commit 852ac43

@paulopmx
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey Guys, how come I can't see this change on the vuex.esm dist file?

@yyx990803
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because this was merged after the latest release and not released yet.

Please sign in to comment.