提交 fe005f7e 编写于 作者: fxy060608's avatar fxy060608

fix(app): createSelectorQuery.in support ComponentInternalInstance (#3105)

上级 53d3c1b7
......@@ -118,7 +118,6 @@ export {
export { handlePromise } from './helpers/api/promise'
export { invokeApi, wrapperReturnValue } from './helpers/interceptor'
export { requestComponentObserver } from './helpers/requestComponentObserver'
// types
export { DefineAsyncApiFn } from './helpers/api'
import { ComponentPublicInstance } from 'vue'
import { extend, isFunction } from '@vue/shared'
import { resolveComponentInstance } from '@dcloudio/uni-shared'
import { getCurrentPageVm, getPageIdByVm } from '@dcloudio/uni-core'
import {
addIntersectionObserver,
......@@ -96,6 +97,7 @@ class ServiceIntersectionObserver {
export const createIntersectionObserver = defineSyncApi<
typeof uni.createIntersectionObserver
>('createIntersectionObserver', (context?, options?) => {
context = resolveComponentInstance(context)
if (context && !getPageIdByVm(context)) {
options = context
context = null
......
import { ComponentPublicInstance } from 'vue'
import { isFunction } from '@vue/shared'
import { resolveComponentInstance } from '@dcloudio/uni-shared'
import { getCurrentPageVm, getPageIdByVm } from '@dcloudio/uni-core'
import { defineSyncApi } from '../../helpers/api'
import {
......@@ -65,6 +66,7 @@ class ServiceMediaQueryObserver {
export const createMediaQueryObserver = defineSyncApi<
typeof uni.createMediaQueryObserver
>('createMediaQueryObserver', (context?: any) => {
context = resolveComponentInstance(context)
if (context && !getPageIdByVm(context)) {
context = null
}
......
import { ComponentPublicInstance } from 'vue'
import { ComponentInternalInstance, ComponentPublicInstance } from 'vue'
import { resolveComponentInstance } from '@dcloudio/uni-shared'
import { getCurrentPageVm, getPageIdByVm } from '@dcloudio/uni-core'
import { requestComponentInfo } from '@dcloudio/uni-platform'
import { getContextInfo } from '@dcloudio/uni-components'
import { defineSyncApi } from '../../helpers/api'
import { CanvasContext } from '../context/canvas'
import { EditorContext } from '../context/editor'
import { MapContext } from '../context/createMapContext'
import { VideoContext } from '../context/createVideoContext'
import { requestComponentInfo } from '@dcloudio/uni-platform'
import { getContextInfo } from '@dcloudio/uni-components'
type NodeField = UniApp.NodeField
export interface SelectorQueryNodeInfo
......@@ -153,8 +154,8 @@ class SelectorQuery implements UniApp.SelectorQuery {
return this._nodesRef as NodesRef
}
in(component?: ComponentPublicInstance) {
this._component = component || undefined
in(component?: ComponentPublicInstance | ComponentInternalInstance) {
this._component = resolveComponentInstance(component)
return this
}
......@@ -199,6 +200,7 @@ class SelectorQuery implements UniApp.SelectorQuery {
export const createSelectorQuery = <typeof uni.createSelectorQuery>(
defineSyncApi('createSelectorQuery', (context?: any) => {
context = resolveComponentInstance(context)
if (context && !getPageIdByVm(context)) {
context = null
}
......
......@@ -194,6 +194,14 @@ var serviceContext = (function (vue) {
const ON_APP_ENTER_BACKGROUND = 'onAppEnterBackground';
const ON_WXS_INVOKE_CALL_METHOD = 'onWxsInvokeCallMethod';
function isComponentInternalInstance(vm) {
return !!vm.appContext;
}
function resolveComponentInstance(instance) {
return (instance &&
(isComponentInternalInstance(instance) ? instance.proxy : instance));
}
let lastLogTime = 0;
function formatLog(module, ...args) {
const now = Date.now();
......@@ -2066,7 +2074,8 @@ var serviceContext = (function (vue) {
});
}
function getPageIdByVm(vm) {
function getPageIdByVm(instance) {
const vm = resolveComponentInstance(instance);
if (vm.$page) {
return vm.$page.id;
}
......@@ -11007,6 +11016,7 @@ var serviceContext = (function (vue) {
}
}
const createIntersectionObserver = defineSyncApi('createIntersectionObserver', (context, options) => {
context = resolveComponentInstance(context);
if (context && !getPageIdByVm(context)) {
options = context;
context = null;
......@@ -11044,6 +11054,7 @@ var serviceContext = (function (vue) {
}
}
const createMediaQueryObserver = defineSyncApi('createMediaQueryObserver', (context) => {
context = resolveComponentInstance(context);
if (context && !getPageIdByVm(context)) {
context = null;
}
......@@ -11207,7 +11218,7 @@ var serviceContext = (function (vue) {
return this._nodesRef;
}
in(component) {
this._component = component || undefined;
this._component = resolveComponentInstance(component);
return this;
}
select(selector) {
......@@ -11230,6 +11241,7 @@ var serviceContext = (function (vue) {
}
}
const createSelectorQuery = (defineSyncApi('createSelectorQuery', (context) => {
context = resolveComponentInstance(context);
if (context && !getPageIdByVm(context)) {
context = null;
}
......
import { addLeadingSlash, EventChannel } from '@dcloudio/uni-shared'
import {
addLeadingSlash,
EventChannel,
resolveComponentInstance,
} from '@dcloudio/uni-shared'
import { extend } from '@vue/shared'
import { ComponentPublicInstance, getCurrentInstance } from 'vue'
import {
ComponentInternalInstance,
ComponentPublicInstance,
getCurrentInstance,
} from 'vue'
import { rpx2px } from './util'
export function useCurrentPageId() {
......@@ -11,7 +19,10 @@ export function useCurrentPageId() {
return getCurrentInstance()!.root.proxy!.$page.id
}
export function getPageIdByVm(vm: ComponentPublicInstance) {
export function getPageIdByVm(
instance: ComponentPublicInstance | ComponentInternalInstance
) {
const vm = resolveComponentInstance(instance)!
if (vm.$page) {
return vm.$page.id
}
......
import { withModifiers, createVNode, getCurrentInstance, ref, defineComponent, openBlock, createElementBlock, provide, computed, watch, onUnmounted, inject, onBeforeUnmount, mergeProps, injectHook, reactive, onActivated, onMounted, nextTick, onBeforeMount, withDirectives, vShow, shallowRef, watchEffect, isVNode, Fragment, markRaw, createTextVNode, onBeforeActivate, onBeforeDeactivate, createBlock, renderList, onDeactivated, createApp, Transition, effectScope, withCtx, KeepAlive, resolveDynamicComponent, createElementVNode, normalizeStyle, renderSlot } from "vue";
import { isString, extend, stringifyStyle, parseStringStyle, isPlainObject, isFunction, capitalize, camelize, isArray, hasOwn, isObject, toRawType, makeMap as makeMap$1, isPromise, hyphenate, invokeArrayFns as invokeArrayFns$1 } from "@vue/shared";
import { once, UNI_STORAGE_LOCALE, I18N_JSON_DELIMITERS, passive, initCustomDataset, addLeadingSlash, invokeArrayFns, resolveOwnerVm, resolveOwnerEl, ON_WXS_INVOKE_CALL_METHOD, normalizeTarget, ON_RESIZE, ON_APP_ENTER_FOREGROUND, ON_APP_ENTER_BACKGROUND, ON_SHOW, ON_HIDE, ON_PAGE_SCROLL, ON_REACH_BOTTOM, EventChannel, SCHEME_RE, DATA_RE, getCustomDataset, LINEFEED, ON_ERROR, callOptions, ON_LAUNCH, PRIMARY_COLOR, removeLeadingSlash, getLen, debounce, ON_LOAD, UniLifecycleHooks, NAVBAR_HEIGHT, parseQuery, ON_UNLOAD, ON_REACH_BOTTOM_DISTANCE, decodedQuery, WEB_INVOKE_APPSERVICE, ON_WEB_INVOKE_APP_SERVICE, updateElementStyle, ON_BACK_PRESS, parseUrl, addFont, scrollTo, RESPONSIVE_MIN_WIDTH, formatDateTime, ON_NAVIGATION_BAR_BUTTON_TAP, ON_NAVIGATION_BAR_SEARCH_INPUT_CLICKED, ON_NAVIGATION_BAR_SEARCH_INPUT_FOCUS_CHANGED, ON_NAVIGATION_BAR_SEARCH_INPUT_CHANGED, ON_NAVIGATION_BAR_SEARCH_INPUT_CONFIRMED, ON_PULL_DOWN_REFRESH } from "@dcloudio/uni-shared";
import { once, UNI_STORAGE_LOCALE, I18N_JSON_DELIMITERS, passive, initCustomDataset, resolveComponentInstance, addLeadingSlash, invokeArrayFns, resolveOwnerVm, resolveOwnerEl, ON_WXS_INVOKE_CALL_METHOD, normalizeTarget, ON_RESIZE, ON_APP_ENTER_FOREGROUND, ON_APP_ENTER_BACKGROUND, ON_SHOW, ON_HIDE, ON_PAGE_SCROLL, ON_REACH_BOTTOM, EventChannel, SCHEME_RE, DATA_RE, getCustomDataset, LINEFEED, ON_ERROR, callOptions, ON_LAUNCH, PRIMARY_COLOR, removeLeadingSlash, getLen, debounce, ON_LOAD, UniLifecycleHooks, NAVBAR_HEIGHT, parseQuery, ON_UNLOAD, ON_REACH_BOTTOM_DISTANCE, decodedQuery, WEB_INVOKE_APPSERVICE, ON_WEB_INVOKE_APP_SERVICE, updateElementStyle, ON_BACK_PRESS, parseUrl, addFont, scrollTo, RESPONSIVE_MIN_WIDTH, formatDateTime, ON_NAVIGATION_BAR_BUTTON_TAP, ON_NAVIGATION_BAR_SEARCH_INPUT_CLICKED, ON_NAVIGATION_BAR_SEARCH_INPUT_FOCUS_CHANGED, ON_NAVIGATION_BAR_SEARCH_INPUT_CHANGED, ON_NAVIGATION_BAR_SEARCH_INPUT_CONFIRMED, ON_PULL_DOWN_REFRESH } from "@dcloudio/uni-shared";
import { initVueI18n, isI18nStr, LOCALE_EN, LOCALE_ES, LOCALE_FR, LOCALE_ZH_HANS, LOCALE_ZH_HANT } from "@dcloudio/uni-i18n";
import { useRoute, createRouter, createWebHistory, createWebHashHistory, useRouter, isNavigationFailure, RouterView } from "vue-router";
const isEnableLocale = once(() => typeof __uniConfig !== "undefined" && __uniConfig.locales && !!Object.keys(__uniConfig.locales).length);
......@@ -848,7 +848,8 @@ function createSvgIconVNode(path, color = "#000", size = 27) {
function useCurrentPageId() {
return getCurrentInstance().root.proxy.$page.id;
}
function getPageIdByVm(vm) {
function getPageIdByVm(instance2) {
const vm = resolveComponentInstance(instance2);
if (vm.$page) {
return vm.$page.id;
}
......@@ -4092,6 +4093,7 @@ class ServiceIntersectionObserver {
}
}
const createIntersectionObserver = /* @__PURE__ */ defineSyncApi("createIntersectionObserver", (context, options) => {
context = resolveComponentInstance(context);
if (context && !getPageIdByVm(context)) {
options = context;
context = null;
......@@ -4127,6 +4129,7 @@ class ServiceMediaQueryObserver {
}
}
const createMediaQueryObserver = /* @__PURE__ */ defineSyncApi("createMediaQueryObserver", (context) => {
context = resolveComponentInstance(context);
if (context && !getPageIdByVm(context)) {
context = null;
}
......@@ -4283,7 +4286,7 @@ class SelectorQuery {
return this._nodesRef;
}
in(component) {
this._component = component || void 0;
this._component = resolveComponentInstance(component);
return this;
}
select(selector) {
......@@ -4306,6 +4309,7 @@ class SelectorQuery {
}
}
const createSelectorQuery = /* @__PURE__ */ defineSyncApi("createSelectorQuery", (context) => {
context = resolveComponentInstance(context);
if (context && !getPageIdByVm(context)) {
context = null;
}
......
......@@ -160,6 +160,13 @@ const ON_APP_ENTER_BACKGROUND = 'onAppEnterBackground';
const ON_WEB_INVOKE_APP_SERVICE = 'onWebInvokeAppService';
const ON_WXS_INVOKE_CALL_METHOD = 'onWxsInvokeCallMethod';
function isComponentInternalInstance(vm) {
return !!vm.appContext;
}
function resolveComponentInstance(instance) {
return (instance &&
(isComponentInternalInstance(instance) ? instance.proxy : instance));
}
function resolveOwnerVm(vm) {
if (!vm) {
return;
......@@ -1325,6 +1332,7 @@ exports.initCustomDataset = initCustomDataset;
exports.invokeArrayFns = invokeArrayFns;
exports.isAppNativeTag = isAppNativeTag;
exports.isBuiltInComponent = isBuiltInComponent;
exports.isComponentInternalInstance = isComponentInternalInstance;
exports.isComponentTag = isComponentTag;
exports.isH5CustomElement = isH5CustomElement;
exports.isH5NativeTag = isH5NativeTag;
......@@ -1340,6 +1348,7 @@ exports.parseUrl = parseUrl;
exports.passive = passive;
exports.plusReady = plusReady;
exports.removeLeadingSlash = removeLeadingSlash;
exports.resolveComponentInstance = resolveComponentInstance;
exports.resolveOwnerEl = resolveOwnerEl;
exports.resolveOwnerVm = resolveOwnerVm;
exports.sanitise = sanitise;
......
import type { ComponentInternalInstance } from '@vue/runtime-core';
import { ComponentOptionsBase } from '@vue/runtime-core';
import { ComponentPublicInstance } from '@vue/runtime-core';
import type { ComponentPublicInstance } from '@vue/runtime-core';
import { ComponentPublicInstance as ComponentPublicInstance_2 } from 'vue';
import { createApp } from 'vue';
import { RendererNode } from '@vue/runtime-core';
......@@ -224,6 +224,8 @@ export declare function isAppNativeTag(tag: string): boolean;
export declare function isBuiltInComponent(tag: string): boolean;
export declare function isComponentInternalInstance(vm: unknown): vm is ComponentInternalInstance;
export declare function isComponentTag(tag: string): boolean;
export declare function isH5CustomElement(tag: string): boolean;
......@@ -538,9 +540,11 @@ export declare function removeLeadingSlash(str: string): string;
export declare const RENDERJS_MODULES = "renderjsModules";
export declare function resolveComponentInstance(instance?: ComponentInternalInstance | ComponentPublicInstance): ComponentPublicInstance<{}, {}, {}, {}, {}, {}, {}, {}, false, ComponentOptionsBase<any, any, any, any, any, any, any, any, any, {}>> | undefined;
export declare function resolveOwnerEl(instance: ComponentInternalInstance): RendererNode | null;
export declare function resolveOwnerVm(vm: ComponentInternalInstance): ComponentPublicInstance< {}, {}, {}, {}, {}, {}, {}, {}, false, ComponentOptionsBase<any, any, any, any, any, any, any, any, any, {}>> | undefined;
export declare function resolveOwnerVm(vm: ComponentInternalInstance): ComponentPublicInstance<{}, {}, {}, {}, {}, {}, {}, {}, false, ComponentOptionsBase<any, any, any, any, any, any, any, any, any, {}>> | undefined;
export declare const RESPONSIVE_MIN_WIDTH = 768;
......
......@@ -156,6 +156,13 @@ const ON_APP_ENTER_BACKGROUND = 'onAppEnterBackground';
const ON_WEB_INVOKE_APP_SERVICE = 'onWebInvokeAppService';
const ON_WXS_INVOKE_CALL_METHOD = 'onWxsInvokeCallMethod';
function isComponentInternalInstance(vm) {
return !!vm.appContext;
}
function resolveComponentInstance(instance) {
return (instance &&
(isComponentInternalInstance(instance) ? instance.proxy : instance));
}
function resolveOwnerVm(vm) {
if (!vm) {
return;
......@@ -1198,4 +1205,4 @@ function getEnvLocale() {
return (lang && lang.replace(/[.:].*/, '')) || 'en';
}
export { ACTION_TYPE_ADD_EVENT, ACTION_TYPE_ADD_WXS_EVENT, ACTION_TYPE_CREATE, ACTION_TYPE_EVENT, ACTION_TYPE_INSERT, ACTION_TYPE_PAGE_CREATE, ACTION_TYPE_PAGE_CREATED, ACTION_TYPE_PAGE_SCROLL, ACTION_TYPE_REMOVE, ACTION_TYPE_REMOVE_ATTRIBUTE, ACTION_TYPE_REMOVE_EVENT, ACTION_TYPE_SET_ATTRIBUTE, ACTION_TYPE_SET_TEXT, ATTR_CHANGE_PREFIX, ATTR_CLASS, ATTR_INNER_HTML, ATTR_STYLE, ATTR_TEXT_CONTENT, ATTR_V_OWNER_ID, ATTR_V_RENDERJS, ATTR_V_SHOW, BACKGROUND_COLOR, BUILT_IN_TAGS, BUILT_IN_TAG_NAMES, COMPONENT_NAME_PREFIX, COMPONENT_PREFIX, COMPONENT_SELECTOR_PREFIX, DATA_RE, EventChannel, EventModifierFlags, I18N_JSON_DELIMITERS, JSON_PROTOCOL, LINEFEED, NAVBAR_HEIGHT, NODE_TYPE_COMMENT, NODE_TYPE_ELEMENT, NODE_TYPE_PAGE, NODE_TYPE_TEXT, NVueTextNode, ON_ADD_TO_FAVORITES, ON_APP_ENTER_BACKGROUND, ON_APP_ENTER_FOREGROUND, ON_BACK_PRESS, ON_ERROR, ON_HIDE, ON_KEYBOARD_HEIGHT_CHANGE, ON_LAUNCH, ON_LOAD, ON_NAVIGATION_BAR_BUTTON_TAP, ON_NAVIGATION_BAR_SEARCH_INPUT_CHANGED, ON_NAVIGATION_BAR_SEARCH_INPUT_CLICKED, ON_NAVIGATION_BAR_SEARCH_INPUT_CONFIRMED, ON_NAVIGATION_BAR_SEARCH_INPUT_FOCUS_CHANGED, ON_PAGE_NOT_FOUND, ON_PAGE_SCROLL, ON_PULL_DOWN_REFRESH, ON_REACH_BOTTOM, ON_REACH_BOTTOM_DISTANCE, ON_READY, ON_RESIZE, ON_SHARE_APP_MESSAGE, ON_SHARE_TIMELINE, ON_SHOW, ON_TAB_ITEM_TAP, ON_THEME_CHANGE, ON_UNHANDLE_REJECTION, ON_UNLOAD, ON_WEB_INVOKE_APP_SERVICE, ON_WXS_INVOKE_CALL_METHOD, PLUS_RE, PRIMARY_COLOR, RENDERJS_MODULES, RESPONSIVE_MIN_WIDTH, SCHEME_RE, SELECTED_COLOR, SLOT_DEFAULT_NAME, TABBAR_HEIGHT, TAGS, UNI_SSR, UNI_SSR_DATA, UNI_SSR_GLOBAL_DATA, UNI_SSR_STORE, UNI_SSR_TITLE, UNI_STORAGE_LOCALE, UniBaseNode, UniCommentNode, UniElement, UniEvent, UniInputElement, UniLifecycleHooks, UniNode, UniTextAreaElement, UniTextNode, WEB_INVOKE_APPSERVICE, WXS_MODULES, WXS_PROTOCOL, addFont, addLeadingSlash, cache, cacheStringFunction, callOptions, createIsCustomElement, createRpx2Unit, createUniEvent, debounce, decode, decodedQuery, defaultMiniProgramRpx2Unit, defaultRpx2Unit, dynamicSlotName, forcePatchProp, formatAppLog, formatDateTime, formatH5Log, formatLog, getCustomDataset, getEnvLocale, getLen, getValueByDataPath, initCustomDataset, invokeArrayFns, isAppNativeTag, isBuiltInComponent, isComponentTag, isH5CustomElement, isH5NativeTag, isMiniProgramNativeTag, isRootHook, normalizeDataset, normalizeEventType, normalizeTarget, once, parseEventName, parseQuery, parseUrl, passive, plusReady, removeLeadingSlash, resolveOwnerEl, resolveOwnerVm, sanitise, scrollTo, stringifyQuery, updateElementStyle };
export { ACTION_TYPE_ADD_EVENT, ACTION_TYPE_ADD_WXS_EVENT, ACTION_TYPE_CREATE, ACTION_TYPE_EVENT, ACTION_TYPE_INSERT, ACTION_TYPE_PAGE_CREATE, ACTION_TYPE_PAGE_CREATED, ACTION_TYPE_PAGE_SCROLL, ACTION_TYPE_REMOVE, ACTION_TYPE_REMOVE_ATTRIBUTE, ACTION_TYPE_REMOVE_EVENT, ACTION_TYPE_SET_ATTRIBUTE, ACTION_TYPE_SET_TEXT, ATTR_CHANGE_PREFIX, ATTR_CLASS, ATTR_INNER_HTML, ATTR_STYLE, ATTR_TEXT_CONTENT, ATTR_V_OWNER_ID, ATTR_V_RENDERJS, ATTR_V_SHOW, BACKGROUND_COLOR, BUILT_IN_TAGS, BUILT_IN_TAG_NAMES, COMPONENT_NAME_PREFIX, COMPONENT_PREFIX, COMPONENT_SELECTOR_PREFIX, DATA_RE, EventChannel, EventModifierFlags, I18N_JSON_DELIMITERS, JSON_PROTOCOL, LINEFEED, NAVBAR_HEIGHT, NODE_TYPE_COMMENT, NODE_TYPE_ELEMENT, NODE_TYPE_PAGE, NODE_TYPE_TEXT, NVueTextNode, ON_ADD_TO_FAVORITES, ON_APP_ENTER_BACKGROUND, ON_APP_ENTER_FOREGROUND, ON_BACK_PRESS, ON_ERROR, ON_HIDE, ON_KEYBOARD_HEIGHT_CHANGE, ON_LAUNCH, ON_LOAD, ON_NAVIGATION_BAR_BUTTON_TAP, ON_NAVIGATION_BAR_SEARCH_INPUT_CHANGED, ON_NAVIGATION_BAR_SEARCH_INPUT_CLICKED, ON_NAVIGATION_BAR_SEARCH_INPUT_CONFIRMED, ON_NAVIGATION_BAR_SEARCH_INPUT_FOCUS_CHANGED, ON_PAGE_NOT_FOUND, ON_PAGE_SCROLL, ON_PULL_DOWN_REFRESH, ON_REACH_BOTTOM, ON_REACH_BOTTOM_DISTANCE, ON_READY, ON_RESIZE, ON_SHARE_APP_MESSAGE, ON_SHARE_TIMELINE, ON_SHOW, ON_TAB_ITEM_TAP, ON_THEME_CHANGE, ON_UNHANDLE_REJECTION, ON_UNLOAD, ON_WEB_INVOKE_APP_SERVICE, ON_WXS_INVOKE_CALL_METHOD, PLUS_RE, PRIMARY_COLOR, RENDERJS_MODULES, RESPONSIVE_MIN_WIDTH, SCHEME_RE, SELECTED_COLOR, SLOT_DEFAULT_NAME, TABBAR_HEIGHT, TAGS, UNI_SSR, UNI_SSR_DATA, UNI_SSR_GLOBAL_DATA, UNI_SSR_STORE, UNI_SSR_TITLE, UNI_STORAGE_LOCALE, UniBaseNode, UniCommentNode, UniElement, UniEvent, UniInputElement, UniLifecycleHooks, UniNode, UniTextAreaElement, UniTextNode, WEB_INVOKE_APPSERVICE, WXS_MODULES, WXS_PROTOCOL, addFont, addLeadingSlash, cache, cacheStringFunction, callOptions, createIsCustomElement, createRpx2Unit, createUniEvent, debounce, decode, decodedQuery, defaultMiniProgramRpx2Unit, defaultRpx2Unit, dynamicSlotName, forcePatchProp, formatAppLog, formatDateTime, formatH5Log, formatLog, getCustomDataset, getEnvLocale, getLen, getValueByDataPath, initCustomDataset, invokeArrayFns, isAppNativeTag, isBuiltInComponent, isComponentInternalInstance, isComponentTag, isH5CustomElement, isH5NativeTag, isMiniProgramNativeTag, isRootHook, normalizeDataset, normalizeEventType, normalizeTarget, once, parseEventName, parseQuery, parseUrl, passive, plusReady, removeLeadingSlash, resolveComponentInstance, resolveOwnerEl, resolveOwnerVm, sanitise, scrollTo, stringifyQuery, updateElementStyle };
import type { ComponentInternalInstance, VNode } from '@vue/runtime-core'
import type {
ComponentInternalInstance,
ComponentPublicInstance,
VNode,
} from '@vue/runtime-core'
import { hyphenate } from '@vue/shared'
import { isBuiltInComponent } from './tags'
import { SLOT_DEFAULT_NAME } from './constants'
export function isComponentInternalInstance(
vm: unknown
): vm is ComponentInternalInstance {
return !!(vm as ComponentInternalInstance).appContext
}
export function resolveComponentInstance(
instance?: ComponentInternalInstance | ComponentPublicInstance
) {
return (
instance &&
(isComponentInternalInstance(instance) ? instance.proxy! : instance)
)
}
export function resolveOwnerVm(vm: ComponentInternalInstance) {
if (!vm) {
return
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册