Skip to content

Commit 731b30c

Browse files
committed
Add support for Vue 2.0.x
1 parent fc88c25 commit 731b30c

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

src/create-local-vue.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@ function createLocalVue (): Component {
3232
instance.options._base = instance
3333

3434
// compat for vue-router < 2.7.1 where it does not allow multiple installs
35-
instance._installedPlugins = []
35+
if (instance._installedPlugins && instance._installedPlugins.length) {
36+
instance._installedPlugins.length = 0
37+
}
3638
const use = instance.use
3739
instance.use = (plugin, ...rest) => {
3840
if (plugin.installed === true) {

test/specs/create-local-vue.spec.js

+6-2
Original file line numberDiff line numberDiff line change
@@ -119,15 +119,19 @@ describe('createLocalVue', () => {
119119

120120
class Plugin {}
121121
Plugin.install = function (_Vue) {
122-
expect(_Vue._installedPlugins.indexOf(Plugin)).to.equal(-1)
122+
if (_Vue.installedPlugins) {
123+
expect(_Vue._installedPlugins.indexOf(Plugin)).to.equal(-1)
124+
}
123125
installCount++
124126
}
125127

126128
Vue.use(Plugin)
127129
const localVue = createLocalVue()
128130
localVue.use(Plugin)
129131

130-
expect(localVue._installedPlugins.indexOf(Plugin)).to.equal(0)
132+
if (localVue._installedPlugins) {
133+
expect(localVue._installedPlugins.indexOf(Plugin)).to.equal(0)
134+
}
131135
expect(installCount).to.equal(2)
132136
})
133137

0 commit comments

Comments
 (0)