feat(templateRef): should work with direct reactive property

close #901
This commit is contained in:
Evan You
2020-03-31 10:35:49 -04:00
parent 55b364decc
commit 449ab039fe
2 changed files with 28 additions and 11 deletions

View File

@@ -5,7 +5,8 @@ import {
render,
nextTick,
Ref,
defineComponent
defineComponent,
reactive
} from '@vue/runtime-test'
// reference: https://vue-composition-api-rfc.netlify.com/api.html#template-refs
@@ -200,4 +201,22 @@ describe('api: template refs', () => {
expect(spy).toHaveBeenCalledWith('div')
})
it('should work with direct reactive property', () => {
const root = nodeOps.createElement('div')
const state = reactive({
refKey: null
})
const Comp = {
setup() {
return state
},
render() {
return h('div', { ref: 'refKey' })
}
}
render(h(Comp), root)
expect(state.refKey).toBe(root.children[0])
})
})