Skip to content

Commit 464e39b

Browse files
author
Hiroki Osame
committed
test(component-slot): new child vnode gets destroyed instead of old one
fix vuejs#8337
1 parent 1e77d35 commit 464e39b

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

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

+43
Original file line numberDiff line numberDiff line change
@@ -886,4 +886,47 @@ describe('Component slot', () => {
886886
expect(vm.$el.textContent).toBe('foo')
887887
}).then(done)
888888
})
889+
890+
// #8337
891+
it('should not destroy the new child vm', done => {
892+
const Parent = {
893+
render (h) {
894+
return h(this.API.tag, this.$slots.default)
895+
},
896+
data () {
897+
return { API: { tag: 'p' }}
898+
},
899+
provide () {
900+
return { key: this.API }
901+
}
902+
}
903+
904+
const Child = {
905+
template: '<div></div>',
906+
inject: { wrapper: 'key' },
907+
created () {
908+
this.wrapper.tag = 'div'
909+
}
910+
}
911+
912+
const vm = new Vue({
913+
components: {
914+
Child,
915+
Parent
916+
},
917+
template: `
918+
<parent>
919+
<div>
920+
<child ref="child" />
921+
</div>
922+
</parent>
923+
`
924+
}).$mount()
925+
926+
expect(vm.$refs.child).toBeDefined()
927+
928+
waitForUpdate(() => {
929+
expect(vm.$refs.child).toBeDefined()
930+
}).then(done)
931+
})
889932
})

0 commit comments

Comments
 (0)