( type: AssetTypes, name: string, warnMissing = true, maybeSelfReference = false, )
| 75 | function resolveAsset(type: typeof FILTERS, name: string): Function | undefined |
| 76 | // implementation |
| 77 | function resolveAsset( |
| 78 | type: AssetTypes, |
| 79 | name: string, |
| 80 | warnMissing = true, |
| 81 | maybeSelfReference = false, |
| 82 | ) { |
| 83 | const instance = currentRenderingInstance || currentInstance |
| 84 | if (instance) { |
| 85 | const Component = instance.type |
| 86 | |
| 87 | // explicit self name has highest priority |
| 88 | if (type === COMPONENTS) { |
| 89 | const selfName = getComponentName( |
| 90 | Component, |
| 91 | false /* do not include inferred name to avoid breaking existing code */, |
| 92 | ) |
| 93 | if ( |
| 94 | selfName && |
| 95 | (selfName === name || |
| 96 | selfName === camelize(name) || |
| 97 | selfName === capitalize(camelize(name))) |
| 98 | ) { |
| 99 | return Component |
| 100 | } |
| 101 | } |
| 102 | |
| 103 | const res = |
| 104 | // local registration |
| 105 | // check instance[type] first which is resolved for options API |
| 106 | resolve(instance[type] || (Component as ComponentOptions)[type], name) || |
| 107 | // global registration |
| 108 | resolve(instance.appContext[type], name) |
| 109 | |
| 110 | if (!res && maybeSelfReference) { |
| 111 | // fallback to implicit self-reference |
| 112 | return Component |
| 113 | } |
| 114 | |
| 115 | if (__DEV__ && warnMissing && !res) { |
| 116 | const extra = |
| 117 | type === COMPONENTS |
| 118 | ? `\nIf this is a native custom element, make sure to exclude it from ` + |
| 119 | `component resolution via compilerOptions.isCustomElement.` |
| 120 | : `` |
| 121 | warn(`Failed to resolve ${type.slice(0, -1)}: ${name}${extra}`) |
| 122 | } |
| 123 | |
| 124 | return res |
| 125 | } else if (__DEV__) { |
| 126 | warn( |
| 127 | `resolve${capitalize(type.slice(0, -1))} ` + |
| 128 | `can only be used in render() or setup().`, |
| 129 | ) |
| 130 | } |
| 131 | } |
| 132 | |
| 133 | function resolve(registry: Record<string, any> | undefined, name: string) { |
| 134 | return ( |
no test coverage detected