Skip to content

Commit fcad48a

Browse files
author
Jeremy Cassou
committed
fix: support v-text on child functional components with shallowMount
a child functional component must display content of v-text directive when it is mounted with shallowMount fix vuejs#1693
1 parent c4c940d commit fcad48a

File tree

4 files changed

+14
-2
lines changed

4 files changed

+14
-2
lines changed

packages/create-instance/create-component-stubs.js

+3
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,9 @@ export function createStubFromComponent(
135135
tagName,
136136
{
137137
ref: componentOptions.functional ? context.data.ref : undefined,
138+
domProps: componentOptions.functional
139+
? context.data.domProps
140+
: undefined,
138141
attrs: componentOptions.functional
139142
? {
140143
...context.props,

test/resources/components/component-with-functional-child.vue

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<template>
22
<functional-component
33
:class="{ bar: a + b === 2, foo: a === 1, qux: a === 2 }"
4+
v-text="something"
45
/>
56
</template>
67

@@ -15,7 +16,8 @@ export default {
1516
data() {
1617
return {
1718
a: 1,
18-
b: 1
19+
b: 1,
20+
something: 'value'
1921
}
2022
}
2123
}
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
<template functional>
2-
<div />
2+
<div>
3+
<slot />
4+
</div>
35
</template>

test/specs/shallow-mount.spec.js

+5
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@ describeRunIf(process.env.TEST_ENV !== 'node', 'shallowMount', () => {
4141
)
4242
})
4343

44+
it('renders v-text content of functional child', () => {
45+
const wrapper = shallowMount(ComponentWithFunctionalChild)
46+
expect(wrapper.find('functional-component-stub').text()).toBe('value')
47+
})
48+
4449
it('returns new VueWrapper of Vue localVue if no options are passed', () => {
4550
const compiled = compileToFunctions('<div><input /></div>')
4651
const wrapper = shallowMount(compiled)

0 commit comments

Comments
 (0)