})
test('expose should allow access to built-in instance properties', () => {
+ const GrandChild = defineComponent({
+ render() {
+ return h('div')
+ }
+ })
+
+ const grandChildRef = ref()
const Child = defineComponent({
render() {
return h('div')
},
setup(_, { expose }) {
expose()
- return {}
+ return () => h(GrandChild, { ref: grandChildRef })
}
})
const root = nodeOps.createElement('div')
render(h(Parent), root)
expect(childRef.value.$el.tag).toBe('div')
+ expect(grandChildRef.value.$parent).toBe(childRef.value)
+ expect(grandChildRef.value.$parent.$parent).toBe(grandChildRef.value.$root)
})
})
import {
ComponentInternalInstance,
Data,
+ getExposeProxy,
isStatefulComponent
} from './component'
import { nextTick, queueJob } from './scheduler'
i: ComponentInternalInstance | null
): ComponentPublicInstance | ComponentInternalInstance['exposed'] | null => {
if (!i) return null
- if (isStatefulComponent(i)) return i.exposed ? i.exposed : i.proxy
+ if (isStatefulComponent(i)) return getExposeProxy(i) || i.proxy
return getPublicInstance(i.parent)
}