Skip to content

Commit

Permalink
fix(util): retain parent-child relationship for Vue 2
Browse files Browse the repository at this point in the history
  • Loading branch information
xanf committed Oct 26, 2022
1 parent b5b3b1d commit 58e2d7e
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/components/transporter/transporter.spec.js
Expand Up @@ -58,4 +58,28 @@ describe('utils/transporter component', () => {

expect(target.parentElement).toEqual(null)
})

it('maintains provide-inject relation', async () => {
const Child = {
inject: ['foo'],
render(h) {
return h('article', this.foo)
}
}

const App = {
provide() {
return { foo: 'foo' }
},
render(h) {
return h(BVTransporter, { props: { disabled: false } }, [h(Child)])
}
}

mount(App, {
attachTo: document.body
})

expect(document.querySelector('article').textContent).toBe('foo')
})
})
1 change: 1 addition & 0 deletions src/utils/create-new-child-component.js
Expand Up @@ -3,6 +3,7 @@ export const createNewChildComponent = (parent, Component, config = {}) => {

return new Component({
...config,
parent,
bvParent: parent,
bvEventRoot
})
Expand Down

0 comments on commit 58e2d7e

Please sign in to comment.