anchor: any,
parentComponent: ComponentInternalInstance | null,
parentSuspense: SuspenseBoundary | null,
- isSingleRoot?: boolean,
): GenericComponentInstance // VaporComponentInstance
update(n1: VNode, n2: VNode, shouldUpdate: boolean): void
unmount(vnode: VNode, doRemove?: boolean): void
// bail here and wait for re-entry.
instance.asyncDep = setupResult
if (__DEV__ && !instance.suspense) {
- const name = Component.name ?? 'Anonymous'
+ const name = getComponentName(Component) ?? 'Anonymous'
warn(
`Component <${name}>: setup function returned a promise, but no ` +
`<Suspense> boundary was found in the parent component tree. ` +
if (instance.vapor) {
// @ts-expect-error
setupRenderEffect(asyncSetupResult)
- } else {
+ }
+ // vdom component
+ else {
const { vnode } = instance
if (__DEV__) {
pushWarningContext(vnode)
instance.isUnmounted = true
}, parentSuspense)
- // A component with async dep inside a pending suspense is unmounted before
- // its async dep resolves. This should remove the dep from the suspense, and
- // cause the suspense to resolve immediately if that was the last dep.
- if (
- __FEATURE_SUSPENSE__ &&
- parentSuspense &&
- parentSuspense.pendingBranch &&
- !parentSuspense.isUnmounted &&
- instance.asyncDep &&
- !instance.asyncResolved &&
- instance.suspenseId === parentSuspense.pendingId
- ) {
- parentSuspense.deps--
- if (parentSuspense.deps === 0) {
- parentSuspense.resolve()
- }
- }
-
if (__DEV__ || __FEATURE_PROD_DEVTOOLS__) {
devtoolsComponentRemoved(instance)
}
const getNextHostNode: NextFn = vnode => {
if (vnode.shapeFlag & ShapeFlags.COMPONENT) {
if ((vnode.type as ConcreteComponent).__vapor) {
- return hostNextSibling((vnode.component! as any).block)
+ return hostNextSibling(vnode.anchor!)
}
return getNextHostNode(vnode.component!.subTree)
}
: EMPTY_OBJ
const isAsyncSetup = isPromise(setupResult)
- if (__FEATURE_SUSPENSE__ && isAsyncSetup) {
- // async setup returned Promise.
- // bail here and wait for re-entry.
- instance.asyncDep = setupResult
- if (__DEV__ && !instance.suspense) {
- const name = getComponentName(component, true) ?? 'Anonymous'
+ if (isAsyncSetup) {
+ if (__FEATURE_SUSPENSE__) {
+ // async setup returned Promise.
+ // bail here and wait for re-entry.
+ instance.asyncDep = setupResult
+ if (__DEV__ && !instance.suspense) {
+ const name = getComponentName(component) ?? 'Anonymous'
+ warn(
+ `Component <${name}>: setup function returned a promise, but no ` +
+ `<Suspense> boundary was found in the parent component tree. ` +
+ `A component with async setup() must be nested in a <Suspense> ` +
+ `in order to be rendered.`,
+ )
+ }
+ } else if (__DEV__) {
warn(
- `Component <${name}>: setup function returned a promise, but no ` +
- `<Suspense> boundary was found in the parent component tree. ` +
- `A component with async setup() must be nested in a <Suspense> ` +
- `in order to be rendered.`,
+ `setup() returned a Promise, but the version of Vue you are using ` +
+ `does not support it yet.`,
)
}
- }
-
- if (!isAsyncSetup) {
+ } else {
handleSetupResult(setupResult, component, instance, isSingleRoot, setupFn)
}
setupResult: any,
component: VaporComponent,
instance: VaporComponentInstance,
- isSingleRoot: boolean | undefined,
- setupFn: VaporSetupFn | undefined,
+ isSingleRoot?: boolean,
+ setupFn?: VaporSetupFn,
): void {
if (__DEV__) {
pushWarningContext(instance)
VaporInteropInterface,
'vdomMount' | 'vdomUnmount' | 'vdomSlot'
> = {
- mount(
- vnode,
- container,
- anchor,
- parentComponent,
- parentSuspense,
- isSingleRoot,
- ) {
+ mount(vnode, container, anchor, parentComponent, parentSuspense) {
const selfAnchor = (vnode.el = vnode.anchor = createTextNode())
container.insertBefore(selfAnchor, anchor)
const prev = currentInstance
{
_: slotsRef, // pass the slots ref
} as any as RawSlots,
- isSingleRoot,
+ undefined,
undefined,
parentSuspense,
))
instance.rawPropsRef = propsRef
instance.rawSlotsRef = slotsRef
- if (__FEATURE_SUSPENSE__ && instance.asyncDep) {
- parentSuspense &&
- parentSuspense.registerDep(
- instance as any,
- setupResult => {
- handleSetupResult(
- setupResult,
- component,
- instance,
- isSingleRoot,
- isFunction(component) ? component : component.setup,
- )
- mountComponent(instance, container, selfAnchor)
- },
- false,
- )
+ if (__FEATURE_SUSPENSE__ && parentSuspense && instance.asyncDep) {
+ parentSuspense.registerDep(
+ instance as any,
+ (setupResult: any) => {
+ handleSetupResult(
+ setupResult,
+ component,
+ instance,
+ undefined,
+ isFunction(component) ? component : component.setup,
+ )
+ mountComponent(instance, container, selfAnchor)
+ },
+ false,
+ )
} else {
mountComponent(instance, container, selfAnchor)
}