diff --git a/packages/create-instance/create-instance.js b/packages/create-instance/create-instance.js index 2b964a548..abc2e0b7e 100644 --- a/packages/create-instance/create-instance.js +++ b/packages/create-instance/create-instance.js @@ -171,9 +171,13 @@ export default function createInstance ( Constructor, { ref: 'vm', - props: options.propsData, on: options.listeners, - attrs: options.attrs, + attrs: { + ...options.attrs, + // pass as attrs so that inheritAttrs works correctly + // propsData should take precedence over attrs + ...options.propsData + }, scopedSlots }, slots diff --git a/test/specs/mount.spec.js b/test/specs/mount.spec.js index c248915db..203e6c2b0 100644 --- a/test/specs/mount.spec.js +++ b/test/specs/mount.spec.js @@ -321,6 +321,25 @@ describeRunIf(process.env.TEST_ENV !== 'node', 'mount', () => { Vue.config.errorHandler = null }) + it('adds unused propsData as attributes', () => { + const wrapper = mount( + ComponentWithProps, { + attachToDocument: true, + propsData: { + prop1: 'prop1', + extra: 'attr' + }, + attrs: { + height: '50px' + } + }) + + if (vueVersion > 2.3) { + expect(wrapper.vm.$attrs).to.eql({ height: '50px', extra: 'attr' }) + } + expect(wrapper.html()).to.equal(`
prop1