diff --git a/packages/shared/stub-components.js b/packages/shared/stub-components.js index 6bc9250d3..6016e52f9 100644 --- a/packages/shared/stub-components.js +++ b/packages/shared/stub-components.js @@ -102,6 +102,14 @@ function createBlankStub ( render (h, context) { return h( tagName, + { + attrs: componentOptions.functional ? { + ...context.props, + ...context.data.attrs + } : { + ...this.$props + } + }, context ? context.children : this.$slots.default ) } diff --git a/test/specs/shallow-mount.spec.js b/test/specs/shallow-mount.spec.js index 4467fcb8c..3b40db304 100644 --- a/test/specs/shallow-mount.spec.js +++ b/test/specs/shallow-mount.spec.js @@ -138,6 +138,41 @@ describeRunIf(process.env.TEST_ENV !== 'node', 'shallowMount', () => { } ) + itDoNotRunIf( + vueVersion < 2.2, // $props does not exist in Vue < 2.2 + 'renders stubs props', () => { + const TestComponent = { + template: ``, + data: () => ({ + 'propA': 'a' + }), + components: { + child: { + props: ['prop'] + } + } + } + const wrapper = shallowMount(TestComponent) + expect(wrapper.html()).to.contain(' { + const TestComponent = { + template: ``, + data: () => ({ + 'propA': 'a' + }), + components: { + Child: { + props: ['prop'], + functional: true + } + } + } + const wrapper = shallowMount(TestComponent) + expect(wrapper.html()).to.contain(' { const TestComponent = { template: `