Skip to content

Commit

Permalink
fix(slots): fix slots not updating when passing down normal slots as …
Browse files Browse the repository at this point in the history
…$scopedSlots

fix #9699
  • Loading branch information
yyx990803 committed Mar 18, 2019
1 parent 3433ba5 commit ebc1893
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/core/vdom/helpers/normalize-scoped-slots.js
Expand Up @@ -10,8 +10,8 @@ export function normalizeScopedSlots (
prevSlots?: { [key: string]: Function } | void
): any {
let res
const isStable = slots ? !!slots.$stable : true
const hasNormalSlots = Object.keys(normalSlots).length > 0
const isStable = slots ? !!slots.$stable : !hasNormalSlots
const key = slots && slots.$key
if (!slots) {
res = {}
Expand Down
32 changes: 32 additions & 0 deletions test/unit/features/component/component-scoped-slot.spec.js
Expand Up @@ -1277,4 +1277,36 @@ describe('Component scoped slot', () => {
}).$mount()
expect(vm.$el.textContent).toMatch('fallback')
})

// #9699
// Component only has normal slots, but is passing down $scopedSlots directly
// $scopedSlots should not be marked as stable in this case
it('render function passing $scopedSlots w/ normal slots down', done => {
const one = {
template: `<div><slot name="footer"/></div>`
}

const two = {
render(h) {
return h(one, {
scopedSlots: this.$scopedSlots
})
}
}

const vm = new Vue({
data: { count: 0 },
render(h) {
return h(two, [
h('span', { slot: 'footer' }, this.count)
])
}
}).$mount()

expect(vm.$el.textContent).toMatch(`0`)
vm.count++
waitForUpdate(() => {
expect(vm.$el.textContent).toMatch(`1`)
}).then(done)
})
})

0 comments on commit ebc1893

Please sign in to comment.