Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/compiler/codegen/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,14 @@ function containsSlotChild (el: ASTNode): boolean {
if (el.tag === 'slot') {
return true
}
return el.children.some(containsSlotChild)
// #12232, #12245: nested scoped slot should update
const childrenIsDynamic = el.children.some(containsSlotChild)
if (childrenIsDynamic) {
return childrenIsDynamic
} else if (el.scopedSlots) {
const scopedSlots = el.scopedSlots
return Object.keys(scopedSlots).some(key => containsSlotChild(scopedSlots[key]))
}
}
return false
}
Expand Down
66 changes: 66 additions & 0 deletions test/unit/features/component/component-scoped-slot.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1026,6 +1026,72 @@ describe('Component scoped slot', () => {
}).then(done)
})

// #12232, #12245
it('nested named scoped slots should update', done => {
const initialText = 'initial'
const scopedSlotContent = 'scopedSlot'

const inner = {
template: `<div><slot v-bind="{ user: '${scopedSlotContent}' }"/></div>`
}

const innerContainer = {
template: `<div><slot name="content"/></div>`
}

const wrapper = {
components: { inner, innerContainer },
name: 'wrapper',
template: `
<inner v-slot="{ user }">
<innerContainer>
<template #content>
<div>
<span>{{ user }}</span>
<slot/>
</div>
</template>
</innerContainer>
</inner>
`
}

const outer = {
components: { wrapper },
template: `
<wrapper>
<form>
<span>{{ text }}</span>
<input v-model="text" type="text"/>
</form>
</wrapper>
`,
data() {
return {
text: initialText,
}
},
}

const vm = new Vue({
components: { outer },
template: `<outer ref="outer"></outer>`
}).$mount()

expect(vm.$el.textContent).toBe(`${scopedSlotContent} ${initialText} `)

const newValue = 'newValue'
vm.$refs.outer.text = newValue
const input = vm.$el.querySelector('input')
input.value = newValue
triggerEvent(input, 'input')

waitForUpdate(() => {
expect(vm.$el.textContent).toBe(`${scopedSlotContent} ${newValue} `)
expect(input.value).toBe(newValue)
}).then(done)
})

it('dynamic v-bind arguments on <slot>', done => {
const Foo = {
data() {
Expand Down