Skip to content

Commit 58e2d7e

Browse files
committed
fix(util): retain parent-child relationship for Vue 2
1 parent b5b3b1d commit 58e2d7e

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

src/components/transporter/transporter.spec.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,4 +58,28 @@ describe('utils/transporter component', () => {
5858

5959
expect(target.parentElement).toEqual(null)
6060
})
61+
62+
it('maintains provide-inject relation', async () => {
63+
const Child = {
64+
inject: ['foo'],
65+
render(h) {
66+
return h('article', this.foo)
67+
}
68+
}
69+
70+
const App = {
71+
provide() {
72+
return { foo: 'foo' }
73+
},
74+
render(h) {
75+
return h(BVTransporter, { props: { disabled: false } }, [h(Child)])
76+
}
77+
}
78+
79+
mount(App, {
80+
attachTo: document.body
81+
})
82+
83+
expect(document.querySelector('article').textContent).toBe('foo')
84+
})
6185
})

src/utils/create-new-child-component.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ export const createNewChildComponent = (parent, Component, config = {}) => {
33

44
return new Component({
55
...config,
6+
parent,
67
bvParent: parent,
78
bvEventRoot
89
})

0 commit comments

Comments
 (0)