Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion packages/create-instance/create-instance.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,13 @@ export default function createInstance(
createChildren(this, h, options)
)
}
const Parent = _Vue.extend(parentComponentOptions)

// options "propsData" can only be used during instance creation with the `new` keyword
const { propsData, ...rest } = options // eslint-disable-line
const Parent = _Vue.extend({
...rest,
...parentComponentOptions
})

return new Parent()
}
18 changes: 18 additions & 0 deletions test/specs/mount.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,24 @@ describeRunIf(process.env.TEST_ENV !== 'node', 'mount', () => {
expect(wrapper.html()).toEqual('<div>composition api</div>')
})

it('allows accessing $root with composition api plugin', () => {
const localVue = createLocalVue()
localVue.use(Vuex)
localVue.use(CompositionAPI)
const store = new Vuex.Store({
state: {
msg: 'msg'
}
})
const Comp = {
setup(props, ctx) {
return () => createElement('div', ctx.root.$store.state.msg)
}
}
const wrapper = mount(Comp, { localVue, store })
expect(wrapper.html()).toEqual('<div>msg</div>')
})

itDoNotRunIf.skip(
vueVersion >= 2.5,
'throws if component throws during update',
Expand Down