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

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/core/vdom/patch.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,9 @@ export function createPatchFunction (backend) {
// reference node. Instead, we clone the node on-demand before creating
// associated DOM element for it.
vnode = ownerArray[index] = cloneVNode(vnode)
if (vnode.children) {
vnode.children = vnode.children.map(cloneVNode)
}
}

vnode.isRootInsert = !nested // for transition enter check
Expand Down
43 changes: 43 additions & 0 deletions test/unit/features/component/component-slot.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -886,4 +886,47 @@ describe('Component slot', () => {
expect(vm.$el.textContent).toBe('foo')
}).then(done)
})

// #8337
it('should not destroy the new child vm', done => {
const Parent = {
render (h) {
return h(this.API.tag, this.$slots.default)
},
data () {
return { API: { tag: 'p' }}
},
provide () {
return { key: this.API }
}
}

const Child = {
template: '<div></div>',
inject: { wrapper: 'key' },
created () {
this.wrapper.tag = 'div'
}
}

const vm = new Vue({
components: {
Child,
Parent
},
template: `
<parent>
<div>
<child ref="child" />
</div>
</parent>
`
}).$mount()

expect(vm.$refs.child).toBeDefined()

waitForUpdate(() => {
expect(vm.$refs.child).toBeDefined()
}).then(done)
})
})