Skip to content

Commit 0a8322b

Browse files
committed
wip: save
1 parent 7eddeaa commit 0a8322b

File tree

6 files changed

+42
-62
lines changed

6 files changed

+42
-62
lines changed

packages/runtime-core/src/apiCreateApp.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,6 @@ export interface VaporInteropInterface {
183183
anchor: any,
184184
parentComponent: ComponentInternalInstance | null,
185185
parentSuspense: SuspenseBoundary | null,
186-
isSingleRoot?: boolean,
187186
): GenericComponentInstance // VaporComponentInstance
188187
update(n1: VNode, n2: VNode, shouldUpdate: boolean): void
189188
unmount(vnode: VNode, doRemove?: boolean): void

packages/runtime-core/src/component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -939,7 +939,7 @@ function setupStatefulComponent(
939939
// bail here and wait for re-entry.
940940
instance.asyncDep = setupResult
941941
if (__DEV__ && !instance.suspense) {
942-
const name = Component.name ?? 'Anonymous'
942+
const name = getComponentName(Component) ?? 'Anonymous'
943943
warn(
944944
`Component <${name}>: setup function returned a promise, but no ` +
945945
`<Suspense> boundary was found in the parent component tree. ` +

packages/runtime-core/src/components/Suspense.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -714,7 +714,9 @@ function createSuspenseBoundary(
714714
if (instance.vapor) {
715715
// @ts-expect-error
716716
setupRenderEffect(asyncSetupResult)
717-
} else {
717+
}
718+
// vdom component
719+
else {
718720
const { vnode } = instance
719721
if (__DEV__) {
720722
pushWarningContext(vnode)

packages/runtime-core/src/renderer.ts

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2387,24 +2387,6 @@ function baseCreateRenderer(
23872387
instance.isUnmounted = true
23882388
}, parentSuspense)
23892389

2390-
// A component with async dep inside a pending suspense is unmounted before
2391-
// its async dep resolves. This should remove the dep from the suspense, and
2392-
// cause the suspense to resolve immediately if that was the last dep.
2393-
if (
2394-
__FEATURE_SUSPENSE__ &&
2395-
parentSuspense &&
2396-
parentSuspense.pendingBranch &&
2397-
!parentSuspense.isUnmounted &&
2398-
instance.asyncDep &&
2399-
!instance.asyncResolved &&
2400-
instance.suspenseId === parentSuspense.pendingId
2401-
) {
2402-
parentSuspense.deps--
2403-
if (parentSuspense.deps === 0) {
2404-
parentSuspense.resolve()
2405-
}
2406-
}
2407-
24082390
if (__DEV__ || __FEATURE_PROD_DEVTOOLS__) {
24092391
devtoolsComponentRemoved(instance)
24102392
}
@@ -2426,7 +2408,7 @@ function baseCreateRenderer(
24262408
const getNextHostNode: NextFn = vnode => {
24272409
if (vnode.shapeFlag & ShapeFlags.COMPONENT) {
24282410
if ((vnode.type as ConcreteComponent).__vapor) {
2429-
return hostNextSibling((vnode.component! as any).block)
2411+
return hostNextSibling(vnode.anchor!)
24302412
}
24312413
return getNextHostNode(vnode.component!.subTree)
24322414
}

packages/runtime-vapor/src/component.ts

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -217,22 +217,27 @@ export function createComponent(
217217
: EMPTY_OBJ
218218

219219
const isAsyncSetup = isPromise(setupResult)
220-
if (__FEATURE_SUSPENSE__ && isAsyncSetup) {
221-
// async setup returned Promise.
222-
// bail here and wait for re-entry.
223-
instance.asyncDep = setupResult
224-
if (__DEV__ && !instance.suspense) {
225-
const name = getComponentName(component, true) ?? 'Anonymous'
220+
if (isAsyncSetup) {
221+
if (__FEATURE_SUSPENSE__) {
222+
// async setup returned Promise.
223+
// bail here and wait for re-entry.
224+
instance.asyncDep = setupResult
225+
if (__DEV__ && !instance.suspense) {
226+
const name = getComponentName(component) ?? 'Anonymous'
227+
warn(
228+
`Component <${name}>: setup function returned a promise, but no ` +
229+
`<Suspense> boundary was found in the parent component tree. ` +
230+
`A component with async setup() must be nested in a <Suspense> ` +
231+
`in order to be rendered.`,
232+
)
233+
}
234+
} else if (__DEV__) {
226235
warn(
227-
`Component <${name}>: setup function returned a promise, but no ` +
228-
`<Suspense> boundary was found in the parent component tree. ` +
229-
`A component with async setup() must be nested in a <Suspense> ` +
230-
`in order to be rendered.`,
236+
`setup() returned a Promise, but the version of Vue you are using ` +
237+
`does not support it yet.`,
231238
)
232239
}
233-
}
234-
235-
if (!isAsyncSetup) {
240+
} else {
236241
handleSetupResult(setupResult, component, instance, isSingleRoot, setupFn)
237242
}
238243

@@ -532,8 +537,8 @@ export function handleSetupResult(
532537
setupResult: any,
533538
component: VaporComponent,
534539
instance: VaporComponentInstance,
535-
isSingleRoot: boolean | undefined,
536-
setupFn: VaporSetupFn | undefined,
540+
isSingleRoot?: boolean,
541+
setupFn?: VaporSetupFn,
537542
): void {
538543
if (__DEV__) {
539544
pushWarningContext(instance)

packages/runtime-vapor/src/vdomInterop.ts

Lines changed: 17 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,7 @@ const vaporInteropImpl: Omit<
4040
VaporInteropInterface,
4141
'vdomMount' | 'vdomUnmount' | 'vdomSlot'
4242
> = {
43-
mount(
44-
vnode,
45-
container,
46-
anchor,
47-
parentComponent,
48-
parentSuspense,
49-
isSingleRoot,
50-
) {
43+
mount(vnode, container, anchor, parentComponent, parentSuspense) {
5144
const selfAnchor = (vnode.el = vnode.anchor = createTextNode())
5245
container.insertBefore(selfAnchor, anchor)
5346
const prev = currentInstance
@@ -66,28 +59,27 @@ const vaporInteropImpl: Omit<
6659
{
6760
_: slotsRef, // pass the slots ref
6861
} as any as RawSlots,
69-
isSingleRoot,
62+
undefined,
7063
undefined,
7164
parentSuspense,
7265
))
7366
instance.rawPropsRef = propsRef
7467
instance.rawSlotsRef = slotsRef
75-
if (__FEATURE_SUSPENSE__ && instance.asyncDep) {
76-
parentSuspense &&
77-
parentSuspense.registerDep(
78-
instance as any,
79-
setupResult => {
80-
handleSetupResult(
81-
setupResult,
82-
component,
83-
instance,
84-
isSingleRoot,
85-
isFunction(component) ? component : component.setup,
86-
)
87-
mountComponent(instance, container, selfAnchor)
88-
},
89-
false,
90-
)
68+
if (__FEATURE_SUSPENSE__ && parentSuspense && instance.asyncDep) {
69+
parentSuspense.registerDep(
70+
instance as any,
71+
(setupResult: any) => {
72+
handleSetupResult(
73+
setupResult,
74+
component,
75+
instance,
76+
undefined,
77+
isFunction(component) ? component : component.setup,
78+
)
79+
mountComponent(instance, container, selfAnchor)
80+
},
81+
false,
82+
)
9183
} else {
9284
mountComponent(instance, container, selfAnchor)
9385
}

0 commit comments

Comments
 (0)