Skip to content

Commit

Permalink
fix: clone slot nodes for render fn usage as well
Browse files Browse the repository at this point in the history
fix #7041
  • Loading branch information
yyx990803 committed Nov 14, 2017
1 parent df82aeb commit 13196b2
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/core/instance/render-helpers/resolve-slots.js
Expand Up @@ -44,7 +44,7 @@ export function resolveSlots (
}

function isWhitespace (node: VNode): boolean {
return node.isComment || node.text === ' '
return (node.isComment && !node.asyncFactory) || node.text === ' '
}

export function resolveScopedSlots (
Expand Down
4 changes: 3 additions & 1 deletion src/core/instance/render.js
Expand Up @@ -66,7 +66,9 @@ export function renderMixin (Vue: Class<Component>) {
// last render. They need to be cloned to ensure "freshness" for this render.
for (const key in vm.$slots) {
const slot = vm.$slots[key]
if (slot._rendered) {
// _rendered is a flag added by renderSlot, but may not be present
// if the slot is passed from manually written render functions
if (slot._rendered || (slot[0] && slot[0].elm)) {
vm.$slots[key] = cloneVNodes(slot, true /* deep */)
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/platforms/web/runtime/components/transition.js
Expand Up @@ -82,7 +82,7 @@ export default {
abstract: true,

render (h: Function) {
let children: ?Array<VNode> = this.$options._renderChildren
let children: any = this.$slots.default
if (!children) {
return
}
Expand Down
21 changes: 21 additions & 0 deletions test/unit/modules/vdom/patch/edge-cases.spec.js
Expand Up @@ -246,4 +246,25 @@ describe('vdom patch: edge cases', () => {
vm.$el.children[0].click()
expect(spy).toHaveBeenCalled()
})

// #7041
it('transition children with only deep bindings should be patched on update', done => {
const vm = new Vue({
template: `
<div>
<transition>
<div :style="style"></div>
</transition>
</div>
`,
data: () => ({
style: { color: 'red' }
})
}).$mount()
expect(vm.$el.children[0].style.color).toBe('red')
vm.style.color = 'green'
waitForUpdate(() => {
expect(vm.$el.children[0].style.color).toBe('green')
}).then(done)
})
})

0 comments on commit 13196b2

Please sign in to comment.