Skip to content

Commit 17dfdc8

Browse files
authored
fix: handle cloneDeep errors in createLocalVue (#844)
1 parent ef01abf commit 17dfdc8

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

Diff for: packages/test-utils/src/create-local-vue.js

+10-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,16 @@ function createLocalVue (_Vue: Component = Vue): Component {
1111
Object.keys(_Vue).forEach(key => {
1212
if (!instance.hasOwnProperty(key)) {
1313
const original = _Vue[key]
14-
instance[key] =
15-
typeof original === 'object' ? cloneDeep(original) : original
14+
// cloneDeep can fail when cloning Vue instances
15+
// cloneDeep checks that the instance has a Symbol
16+
// which errors in Vue < 2.17 (https://github.com/vuejs/vue/pull/7878)
17+
try {
18+
instance[key] = typeof original === 'object'
19+
? cloneDeep(original)
20+
: original
21+
} catch (e) {
22+
instance[key] = original
23+
}
1624
}
1725
})
1826

Diff for: test/specs/mounting-options/localVue.spec.js

+10
Original file line numberDiff line numberDiff line change
@@ -83,4 +83,14 @@ describeWithMountingMethods('options.localVue', mountingMethod => {
8383
})
8484
expect(localVue.options.created).to.equal(undefined)
8585
})
86+
87+
it('handles merging Vue instances', () => {
88+
const localVue = createLocalVue()
89+
localVue.use((_Vue) => {
90+
_Vue.$el = new _Vue()
91+
})
92+
mountingMethod({ template: '<div />' }, {
93+
localVue
94+
})
95+
})
8696
})

0 commit comments

Comments
 (0)