Skip to content

Commit 48928e1

Browse files
blake-newmaneddyerburgh
authored andcommitted
fix: error being thrown with Vue.extend when functional (#359)
* Hotfix: Fix error being thrown with `Vue.extend` when functional If using `functional` component with `Vue.extend` an error is thrown, this is avoided by checking the options object * test: remove .only
1 parent 30505f7 commit 48928e1

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

src/lib/create-instance.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export default function createConstructor (
2727
addMocks(mountingOptions.mocks, vue)
2828
}
2929

30-
if (component.functional) {
30+
if ((component.options && component.options.functional) || component.functional) {
3131
component = createFunctionalComponent(component, mountingOptions)
3232
} else if (mountingOptions.context) {
3333
throwError(

test/unit/specs/mount/options/context.spec.js

+11
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import Vue from 'vue'
12
import { mount } from '~vue-test-utils'
23
import { vueVersion } from '~resources/test-utils'
34

@@ -34,6 +35,16 @@ describe('context', () => {
3435
expect(fn).to.throw().with.property('message', message)
3536
})
3637

38+
it('does not throw error if functional component with Vue.extend', () => {
39+
const Component = Vue.extend({
40+
functional: true,
41+
render: h => h('div')
42+
})
43+
const context = {}
44+
const fn = () => mount(Component, { context })
45+
expect(fn).not.to.throw()
46+
})
47+
3748
it('throws error if context option is not an object', () => {
3849
const Component = {
3950
functional: true,

0 commit comments

Comments
 (0)