type ComponentInternalInstance,
type ComponentOptions,
type ConcreteComponent,
+ type GenericComponentInstance,
currentInstance,
isInSSRComponentSetup,
} from './component'
) => any
}
-export const isAsyncWrapper = (i: ComponentInternalInstance | VNode): boolean =>
+export const isAsyncWrapper = (i: GenericComponentInstance | VNode): boolean =>
!!(i.type as ComponentOptions).__asyncLoader
/*! #__NO_SIDE_EFFECTS__ */
load()
.then(() => {
loaded.value = true
- if (instance.parent && isKeepAlive(instance.parent.vnode)) {
+ if (
+ instance.parent &&
+ instance.parent.vnode &&
+ isKeepAlive(instance.parent.vnode)
+ ) {
// parent is keep-alive, force update so the loaded component's
// name is taken into account
- instance.parent.update()
+ ;(instance.parent as ComponentInternalInstance).update()
}
})
.catch(err => {
* @internal vapor only
*/
hmrReload?: (newComp: any) => void
+
+ // these only exist on vdom instances
+ vnode?: VNode
+ subTree?: VNode
+
+ /**
+ * Custom Element instance (if component is created by defineCustomElement)
+ * @internal
+ */
+ ce?: ComponentCustomElementInterface
+ /**
+ * is custom element? (kept only for compatibility)
+ * @internal
+ */
+ isCE?: boolean
+ /**
+ * custom element specific HMR method
+ * @internal
+ */
+ ceReload?: (newStyles?: string[]) => void
}
/**
vapor?: never
uid: number
type: ConcreteComponent
- parent: ComponentInternalInstance | null
- root: ComponentInternalInstance
+ parent: GenericComponentInstance | null
+ root: GenericComponentInstance
appContext: AppContext
/**
* Vnode representing this component in its parent's vdom tree
* @internal
*/
inheritAttrs?: boolean
- /**
- * Custom Element instance (if component is created by defineCustomElement)
- * @internal
- */
- ce?: ComponentCustomElementInterface
- /**
- * is custom element? (kept only for compatibility)
- * @internal
- */
- isCE?: boolean
- /**
- * custom element specific HMR method
- * @internal
- */
- ceReload?: (newStyles?: string[]) => void
// the rest are only for stateful components ---------------------------------
/**
}
export function getComponentPublicInstance(
- instance: ComponentInternalInstance,
+ instance: GenericComponentInstance,
): ComponentPublicInstance | ComponentInternalInstance['exposed'] | null {
if (instance.exposed) {
return (
instance.attrs = attrs
}
-function isInHmrContext(instance: ComponentInternalInstance | null) {
+function isInHmrContext(instance: GenericComponentInstance | null) {
while (instance) {
if (instance.type.__hmrId) return true
instance = instance.parent
type Component,
type ComponentInternalInstance,
type Data,
+ type GenericComponentInstance,
getComponentPublicInstance,
isStatefulComponent,
} from './component'
* public $parent chains, skip functional ones and go to the parent instead.
*/
const getPublicInstance = (
- i: ComponentInternalInstance | null,
+ i: GenericComponentInstance | null,
): ComponentPublicInstance | ComponentInternalInstance['exposed'] | null => {
- if (!i) return null
- if (isStatefulComponent(i)) return getComponentPublicInstance(i)
+ if (!i || i.vapor) return null
+ if (isStatefulComponent(i as ComponentInternalInstance))
+ return getComponentPublicInstance(i)
return getPublicInstance(i.parent)
}
el: typeof vnode.el, // HostNode
): void {
while (parent && !parent.vapor) {
- const root = parent.subTree
+ const root = parent.subTree!
if (root.suspense && root.suspense.activeBranch === vnode) {
root.el = vnode.el
}
if (root === vnode) {
- ;(vnode = parent.vnode).el = el
+ ;(vnode = parent.vnode!).el = el
parent = parent.parent
} else {
break
type ComponentInternalInstance,
type ComponentOptions,
type ConcreteComponent,
+ type GenericComponentInstance,
type SetupContext,
getComponentName,
getCurrentInstance,
hook.__wdc ||
(hook.__wdc = () => {
// only fire the hook if the target instance is NOT in a deactivated branch.
- let current: ComponentInternalInstance | null = target
+ let current: GenericComponentInstance | null = target
while (current) {
if (current.isDeactivated) {
return
// arrays.
if (target) {
let current = target.parent
- while (current && current.parent) {
+ while (current && current.parent && current.parent.vnode) {
if (isKeepAlive(current.parent.vnode)) {
injectToKeepAliveRoot(wrappedHook, type, target, current)
}
hook: Function & { __weh?: Function },
type: LifecycleHooks,
target: ComponentInternalInstance,
- keepAliveRoot: ComponentInternalInstance,
+ keepAliveRoot: GenericComponentInstance,
) {
// injectHook wraps the original for error handling, so make sure to remove
// the wrapped version.
// don't end up forcing the same parent to re-render multiple times.
queueJob(() => {
isHmrUpdating = true
- instance.parent!.update()
+ const parent = instance.parent!
+ if (parent.vapor) {
+ parent.hmrRerender!()
+ } else {
+ ;(parent as ComponentInternalInstance).update()
+ }
isHmrUpdating = false
// #6930, #11248 avoid infinite recursion
dirtyInstances.delete(instance)
if (parent.vnode.el === oldNode) {
parent.vnode.el = parent.subTree.el = newNode
}
- parent = parent.parent
+ parent = parent.parent as ComponentInternalInstance
}
}
}
}
if (vnode === root && instance.parent) {
- resolveCssVars(instance.parent, instance.vnode, expectedMap)
+ resolveCssVars(
+ instance.parent as ComponentInternalInstance,
+ instance.vnode,
+ expectedMap,
+ )
}
}
type ComponentOptions,
type ConcreteComponent,
type Data,
+ type GenericComponentInstance,
type LifecycleHook,
createComponentInstance,
getComponentPublicInstance,
vnode: VNode,
scopeId: string | null,
slotScopeIds: string[] | null,
- parentComponent: ComponentInternalInstance | null,
+ parentComponent: GenericComponentInstance | null,
) => {
if (scopeId) {
hostSetScopeId(el, scopeId)
(isSuspense(subTree.type) &&
(subTree.ssContent === vnode || subTree.ssFallback === vnode))
) {
- const parentVNode = parentComponent!.vnode
+ const parentVNode = parentComponent!.vnode!
setScopeId(
el,
parentVNode,
}
} else {
// custom element style injection
- if (root.ce) {
- root.ce._injectChildStyle(type)
+ if ((root as ComponentInternalInstance).ce) {
+ ;(root as ComponentInternalInstance).ce!._injectChildStyle(type)
}
if (__DEV__) {
type ComponentInternalInstance,
type ConcreteComponent,
type Data,
+ type GenericComponentInstance,
isClassComponent,
} from './component'
import type { RawSlots } from './componentSlots'
export function invokeVNodeHook(
hook: VNodeHook,
- instance: ComponentInternalInstance | null,
+ instance: GenericComponentInstance | null,
vnode: VNode,
prevVNode: VNode | null = null,
): void {
import {
- type ComponentInternalInstance,
type Data,
type GenericComponentInstance,
formatComponentName,
})
}
if (isVNode(currentCtx)) {
- const parent: ComponentInternalInstance | null =
+ const parent: GenericComponentInstance | null =
currentCtx.component && currentCtx.component.parent
- currentCtx = parent && parent.vnode
+ currentCtx = (parent && parent.vnode) || parent
} else {
currentCtx = currentCtx.parent
}
vtcKey,
} from './Transition'
import {
+ type ComponentInternalInstance,
type ComponentOptions,
DeprecationTypes,
Fragment,
!rawProps.tag &&
compatUtils.checkCompatEnabled(
DeprecationTypes.TRANSITION_GROUP_ROOT,
- instance.parent,
+ instance.parent as ComponentInternalInstance,
)
) {
tag = 'span'
if (parent && parent.subTree && parent.subTree === cur.vnode) {
// parent is a non-SSR compiled component and is rendering this
// component as root. inherit its scopeId if present.
- cur = parent
+ cur = parent as ComponentInternalInstance
} else {
break
}
if (curVnode.scopeId) {
openTag += ` ${curVnode.scopeId}`
}
- curParent = curParent.parent
+ curParent = curParent.parent as ComponentInternalInstance
}
if (slotScopeId) {
openTag += ` ${slotScopeId}`