withDirectives,
} from '@vue/runtime-test'
import {
- type ComponentInternalInstance,
+ type GenericComponentInstance,
currentInstance,
} from '../src/component'
unmounted,
}
- let _instance: ComponentInternalInstance | null = null
+ let _instance: GenericComponentInstance | null = null
let _vnode: VNode | null = null
let _prevVnode: VNode | null = null
const Comp = {
expect(prevVNode).toBe(_prevVnode)
}) as DirectiveHook)
- let _instance: ComponentInternalInstance | null = null
+ let _instance: GenericComponentInstance | null = null
let _vnode: VNode | null = null
let _prevVnode: VNode | null = null
const Comp = {
unmounted,
}
- let _instance: ComponentInternalInstance | null = null
+ let _instance: GenericComponentInstance | null = null
let _vnode: VNode | null = null
let _prevVnode: VNode | null = null
transformVNodeArgs,
} from '../src/vnode'
import { PatchFlags, ShapeFlags } from '@vue/shared'
-import type { Data } from '@vue/runtime-shared'
+import type { Data } from '../src/component'
import { h, isReactive, reactive, ref, setBlockTracking, withCtx } from '../src'
import { createApp, nodeOps, serializeInner } from '@vue/runtime-test'
import { setCurrentRenderingInstance } from '../src/componentRenderContext'
},
setup() {
- const instance = currentInstance!
+ const instance = currentInstance as ComponentInternalInstance
markAsyncBoundary(instance)
// already resolved
isUnmounted: boolean
isDeactivated: boolean
+ /**
+ * for tracking useId()
+ * first element is the current boundary prefix
+ * second number is the index of the useId call within that boundary
+ * @internal
+ */
+ ids: [string, number, number]
+
// for vapor the following two are dev only
/**
* resolved props options
*/
emitsOptions?: ObjectEmitsOptions | null
- // the following are for error handling logic only
+ /**
+ * Public instance proxy, vdom only
+ */
proxy?: any
+ /**
+ * suspense related
+ * @internal
+ */
+ suspense: SuspenseBoundary | null
// lifecycle
/**
* @internal
*/
render: InternalRenderFunction | null
- /**
- * for tracking useId()
- * first element is the current boundary prefix
- * second number is the index of the useId call within that boundary
- * @internal
- */
- ids: [string, number, number]
/**
* cache for proxy access type to avoid hasOwnProperty calls
* @internal
* @internal
*/
ctx: Data
- /**
- * suspense related
- * @internal
- */
- suspense: SuspenseBoundary | null
/**
* suspense pending batch id
* @internal
-import { type ComponentInternalInstance, currentInstance } from './component'
+import { type ComponentInternalInstance, getCurrentInstance } from './component'
import {
type VNode,
type VNodeChild,
return rawSlot as Slot
}
const normalized = withCtx((...args: any[]) => {
- if (
- __DEV__ &&
- currentInstance &&
- (!ctx || ctx.root === currentInstance.root)
- ) {
- warn(
- `Slot "${key}" invoked outside of the render function: ` +
- `this will not track dependencies used in the slot. ` +
- `Invoke the slot function inside the render function instead.`,
- )
+ if (__DEV__) {
+ const currentInstance = getCurrentInstance()
+ if (currentInstance && (!ctx || ctx.root === currentInstance.root)) {
+ warn(
+ `Slot "${key}" invoked outside of the render function: ` +
+ `this will not track dependencies used in the slot. ` +
+ `Invoke the slot function inside the render function instead.`,
+ )
+ }
}
return normalizeSlotValue(rawSlot(...args))
}, ctx) as Slot
import {
+ type ComponentInternalInstance,
type ComponentOptions,
type ConcreteComponent,
currentInstance,
const res =
// local registration
// check instance[type] first which is resolved for options API
- resolve(instance[type] || (Component as ComponentOptions)[type], name) ||
+ resolve(
+ (instance as ComponentInternalInstance)[type] ||
+ (Component as ComponentOptions)[type],
+ name,
+ ) ||
// global registration
+ // @ts-expect-error filters only exist in compat mode
resolve(instance.appContext[type], name)
if (!res && maybeSelfReference) {
import {
- type ComponentInternalInstance,
- getCurrentInstance,
+ type GenericComponentInstance,
+ getCurrentGenericInstance,
} from '../component'
import { warn } from '../warning'
export function useId(): string {
- const i = getCurrentInstance()
+ const i = getCurrentGenericInstance()
if (i) {
return (i.appContext.config.idPrefix || 'v') + '-' + i.ids[0] + i.ids[1]++
} else if (__DEV__) {
* - components with async setup()
* - components with serverPrefetch
*/
-export function markAsyncBoundary(instance: ComponentInternalInstance): void {
+export function markAsyncBoundary(instance: GenericComponentInstance): void {
instance.ids = [instance.ids[0] + instance.ids[2]++ + '-', 0, 0]
}
}
}
-export function invalidateMount(hooks: LifecycleHook): void {
+export function invalidateMount(hooks: LifecycleHook | undefined): void {
if (hooks) {
for (let i = 0; i < hooks.length; i++)
hooks[i].flags! |= SchedulerJobFlags.DISPOSED
type LifecycleHook,
type NormalizedPropsOptions,
type ObjectEmitsOptions,
+ type SuspenseBoundary,
currentInstance,
nextUid,
popWarningContext,
)
instance.block = []
} else {
+ instance.setupState = setupResult
instance.block = component.render.call(null, setupResult)
}
} else {
refs: Record<string, any>
// for provide / inject
provides: Record<string, any>
+ // for useId
+ ids: [string, number, number]
+ // for suspense
+ suspense: SuspenseBoundary | null
hasFallthrough: boolean
this.vapor = true
this.uid = nextUid()
this.type = comp
- this.parent = currentInstance // TODO when inside
+ this.parent = currentInstance // TODO proper parent source when inside vdom instance
this.appContext = currentInstance
? currentInstance.appContext
: emptyContext
? currentInstance.provides
: Object.create(this.appContext.provides)
this.refs = EMPTY_OBJ
- this.emitted = this.ec = this.exposed = this.propsDefaults = null
+ this.ids = currentInstance ? currentInstance.ids : ['', 0, 0]
+ this.emitted = this.exposed = this.propsDefaults = this.suspense = null
this.isMounted =
this.isUnmounted =
this.isUpdating =