Skip to content

Commit ebc1893

Browse files
committedMar 18, 2019
fix(slots): fix slots not updating when passing down normal slots as $scopedSlots
fix #9699
1 parent 3433ba5 commit ebc1893

File tree

2 files changed

+33
-1
lines changed

2 files changed

+33
-1
lines changed
 

‎src/core/vdom/helpers/normalize-scoped-slots.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ export function normalizeScopedSlots (
1010
prevSlots?: { [key: string]: Function } | void
1111
): any {
1212
let res
13-
const isStable = slots ? !!slots.$stable : true
1413
const hasNormalSlots = Object.keys(normalSlots).length > 0
14+
const isStable = slots ? !!slots.$stable : !hasNormalSlots
1515
const key = slots && slots.$key
1616
if (!slots) {
1717
res = {}

‎test/unit/features/component/component-scoped-slot.spec.js

+32
Original file line numberDiff line numberDiff line change
@@ -1277,4 +1277,36 @@ describe('Component scoped slot', () => {
12771277
}).$mount()
12781278
expect(vm.$el.textContent).toMatch('fallback')
12791279
})
1280+
1281+
// #9699
1282+
// Component only has normal slots, but is passing down $scopedSlots directly
1283+
// $scopedSlots should not be marked as stable in this case
1284+
it('render function passing $scopedSlots w/ normal slots down', done => {
1285+
const one = {
1286+
template: `<div><slot name="footer"/></div>`
1287+
}
1288+
1289+
const two = {
1290+
render(h) {
1291+
return h(one, {
1292+
scopedSlots: this.$scopedSlots
1293+
})
1294+
}
1295+
}
1296+
1297+
const vm = new Vue({
1298+
data: { count: 0 },
1299+
render(h) {
1300+
return h(two, [
1301+
h('span', { slot: 'footer' }, this.count)
1302+
])
1303+
}
1304+
}).$mount()
1305+
1306+
expect(vm.$el.textContent).toMatch(`0`)
1307+
vm.count++
1308+
waitForUpdate(() => {
1309+
expect(vm.$el.textContent).toMatch(`1`)
1310+
}).then(done)
1311+
})
12801312
})

0 commit comments

Comments
 (0)
Please sign in to comment.