Skip to content

Commit 8da1a4e

Browse files
committed
add test for slots
1 parent e6ad08d commit 8da1a4e

File tree

3 files changed

+15
-8
lines changed

3 files changed

+15
-8
lines changed

packages/create-instance/create-instance.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ export default function createInstance (
7171
vm._renderProxy.props = props
7272
return scopedSlotFn.call(vm._renderProxy)
7373
} else {
74-
return renderSlot(name, feedback, props, bindObject)
74+
return renderSlot.call(vm._renderProxy, name, feedback, props, bindObject)
7575
}
7676
}
7777
// $FlowIgnore

test/resources/components/component-with-scoped-slots.vue

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
11
<template>
22
<div>
3-
<slot name="item"
4-
v-for="(item, index) in items"
5-
:text="item.text"
6-
:index="index">
7-
</slot>
3+
<div id="scopedSlots">
4+
<slot name="item"
5+
v-for="(item, index) in items"
6+
:text="item.text"
7+
:index="index">
8+
</slot>
9+
</div>
10+
<div id="slots">
11+
<slot></slot>
12+
</div>
813
</div>
914
</template>
1015

test/specs/mounting-options/scopedSlots.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,15 @@ describeWithShallowAndMount('scopedSlots', (mountingMethod) => {
55
itDoNotRunIf(vueVersion < 2.5,
66
'mounts component scoped slots', () => {
77
const wrapper = mountingMethod(ComponentWithScopedSlots, {
8+
slots: { default: '<span>123</span>' },
89
scopedSlots: {
910
'item': '<p slot-scope="props">{{props.index}},{{props.text}}</p>'
1011
}
1112
})
12-
expect(wrapper.html()).to.equal('<div><p>0,a1</p><p>1,a2</p><p>2,a3</p></div>')
13+
expect(wrapper.find('#slots').html()).to.equal('<div id="slots"><span>123</span></div>')
14+
expect(wrapper.find('#scopedSlots').html()).to.equal('<div id="scopedSlots"><p>0,a1</p><p>1,a2</p><p>2,a3</p></div>')
1315
wrapper.vm.items = [{ text: 'b1' }, { text: 'b2' }, { text: 'b3' }]
14-
expect(wrapper.html()).to.equal('<div><p>0,b1</p><p>1,b2</p><p>2,b3</p></div>')
16+
expect(wrapper.find('#scopedSlots').html()).to.equal('<div id="scopedSlots"><p>0,b1</p><p>1,b2</p><p>2,b3</p></div>')
1517
}
1618
)
1719

0 commit comments

Comments
 (0)