wip: update

This commit is contained in:
daiwei 2025-03-18 17:30:57 +08:00
parent 367924ca9e
commit cbdfdabdf2
1 changed files with 10 additions and 8 deletions

View File

@ -7,7 +7,6 @@ import {
} from './component' } from './component'
import { import {
ErrorCodes, ErrorCodes,
type GenericComponentInstance,
type SchedulerJob, type SchedulerJob,
callWithErrorHandling, callWithErrorHandling,
isAsyncWrapper, isAsyncWrapper,
@ -50,16 +49,19 @@ export function setRef(
refFor = false, refFor = false,
): NodeRef | undefined { ): NodeRef | undefined {
if (!instance || instance.isUnmounted) return if (!instance || instance.isUnmounted) return
const isVaporComp = isVaporComponent(el) const isVaporComp = isVaporComponent(el)
if (isVaporComp && isAsyncWrapper(el as GenericComponentInstance)) { if (isVaporComp && isAsyncWrapper(el as VaporComponentInstance)) {
if (!(el as VaporComponentInstance).type.__asyncResolved) { const i = el as VaporComponentInstance
const frag = (el as VaporComponentInstance).block as DynamicFragment const frag = i.block as DynamicFragment
frag.setRef = (el: RefEl) => setRef(instance, el, ref, oldRef, refFor) // async component not resolved yet
if (!i.type.__asyncResolved) {
frag.setRef = n => setRef(instance, n, ref, oldRef, refFor)
return return
} else {
el = ((el as VaporComponentInstance).block as DynamicFragment)
.nodes as RefEl
} }
// set ref to the inner component instead
el = frag.nodes as VaporComponentInstance
} }
const setupState: any = __DEV__ ? instance.setupState || {} : null const setupState: any = __DEV__ ? instance.setupState || {} : null