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

Function resolveTarget

packages/runtime-core/src/components/Teleport.ts:45–76  ·  view source on GitHub ↗
(
  props: TeleportProps | null,
  select: RendererOptions['querySelector'],
)

Source from the content-addressed store, hash-verified

43 typeof MathMLElement === 'function' && target instanceof MathMLElement
44
45const resolveTarget = <T = RendererElement>(
46 props: TeleportProps | null,
47 select: RendererOptions['querySelector'],
48): T | null => {
49 const targetSelector = props && props.to
50 if (isString(targetSelector)) {
51 if (!select) {
52 __DEV__ &&
53 warn(
54 `Current renderer does not support string target for Teleports. ` +
55 `(missing querySelector renderer option)`,
56 )
57 return null
58 } else {
59 const target = select(targetSelector)
60 if (__DEV__ && !target && !isTeleportDisabled(props)) {
61 warn(
62 `Failed to locate Teleport target with selector "${targetSelector}". ` +
63 `Note the target element must exist before the component is mounted - ` +
64 `i.e. the target cannot be rendered by the component itself, and ` +
65 `ideally should be outside of the entire Vue component tree.`,
66 )
67 }
68 return target as T
69 }
70 } else {
71 if (__DEV__ && !targetSelector && !isTeleportDisabled(props)) {
72 warn(`Invalid Teleport target: ${targetSelector}`)
73 }
74 return targetSelector as T
75 }
76}
77
78export const TeleportImpl = {
79 name: 'Teleport',

Callers 3

mountToTargetFunction · 0.85
processFunction · 0.85
hydrateTeleportFunction · 0.85

Calls 3

isStringFunction · 0.90
warnFunction · 0.90
isTeleportDisabledFunction · 0.85

Tested by

no test coverage detected