feat(expose): always expose $ instance properties on child refs

This commit is contained in:
Evan You
2021-06-24 21:28:09 -04:00
parent a5a66c5196
commit b0203a3092
5 changed files with 75 additions and 29 deletions

View File

@@ -7,7 +7,7 @@ describe('api: expose', () => {
render() {},
setup(_, { expose }) {
expose({
foo: ref(1),
foo: 1,
bar: ref(2)
})
return {
@@ -169,4 +169,26 @@ describe('api: expose', () => {
const root = nodeOps.createElement('div')
render(h(Parent), root)
})
test('expose should allow access to built-in instance properties', () => {
const Child = defineComponent({
render() {
return h('div')
},
setup(_, { expose }) {
expose()
return {}
}
})
const childRef = ref()
const Parent = {
setup() {
return () => h(Child, { ref: childRef })
}
}
const root = nodeOps.createElement('div')
render(h(Parent), root)
expect(childRef.value.$el.tag).toBe('div')
})
})