MCPcopy
hub / github.com/vuejs/core / useHost

Function useHost

packages/runtime-dom/src/apiCustomElement.ts:803–821  ·  view source on GitHub ↗
(caller?: string)

Source from the content-addressed store, hash-verified

801}
802
803export function useHost(caller?: string): VueElement | null {
804 const instance = getCurrentInstance()
805 const el = instance && (instance.ce as VueElement)
806 if (el) {
807 return el
808 } else if (__DEV__) {
809 if (!instance) {
810 warn(
811 `${caller || 'useHost'} called without an active component instance.`,
812 )
813 } else {
814 warn(
815 `${caller || 'useHost'} can only be used in components defined via ` +
816 `defineCustomElement.`,
817 )
818 }
819 }
820 return null
821}
822
823/**
824 * Retrieve the shadowRoot of the current custom element. Only usable in setup()

Callers 3

setupFunction · 0.90
useShadowRootFunction · 0.85
setupFunction · 0.85

Calls 2

getCurrentInstanceFunction · 0.90
warnFunction · 0.90

Tested by 2

setupFunction · 0.72
setupFunction · 0.68