1
1
import { type Ref , isRef , onScopeDispose } from '@vue/reactivity'
2
2
import {
3
- type ComponentInternalInstance ,
3
+ type VaporComponentInstance ,
4
4
currentInstance ,
5
5
isVaporComponent ,
6
- } from '../_old/component'
7
- import { VaporErrorCodes , callWithErrorHandling } from '../_old/errorHandling'
6
+ } from '../component'
7
+ import {
8
+ type SchedulerJob ,
9
+ callWithErrorHandling ,
10
+ queuePostFlushCb ,
11
+ warn ,
12
+ } from '@vue/runtime-dom'
8
13
import {
9
14
EMPTY_OBJ ,
10
15
hasOwn ,
@@ -13,11 +18,9 @@ import {
13
18
isString ,
14
19
remove ,
15
20
} from '@vue/shared'
16
- import { warn } from '../_old/warning'
17
- import { type SchedulerJob , queuePostFlushCb } from '../_old/scheduler'
18
21
19
22
export type NodeRef = string | Ref | ( ( ref : Element ) => void )
20
- export type RefEl = Element | ComponentInternalInstance
23
+ export type RefEl = Element | VaporComponentInstance
21
24
22
25
/**
23
26
* Function for handling a template ref
@@ -29,6 +32,7 @@ export function setRef(
29
32
refFor = false ,
30
33
) : NodeRef | undefined {
31
34
if ( ! currentInstance ) return
35
+ // @ts -expect-error TODO
32
36
const { setupState, isUnmounted } = currentInstance
33
37
34
38
if ( isUnmounted ) {
@@ -46,7 +50,7 @@ export function setRef(
46
50
if ( oldRef != null && oldRef !== ref ) {
47
51
if ( isString ( oldRef ) ) {
48
52
refs [ oldRef ] = null
49
- if ( hasOwn ( setupState , oldRef ) ) {
53
+ if ( setupState && hasOwn ( setupState , oldRef ) ) {
50
54
setupState [ oldRef ] = null
51
55
}
52
56
} else if ( isRef ( oldRef ) ) {
@@ -59,7 +63,8 @@ export function setRef(
59
63
callWithErrorHandling (
60
64
ref ,
61
65
currentInstance ,
62
- VaporErrorCodes . FUNCTION_REF ,
66
+ // @ts -expect-error
67
+ null ,
63
68
[ value , refs ] ,
64
69
)
65
70
}
@@ -126,7 +131,7 @@ export function setRef(
126
131
} )
127
132
} )
128
133
} else if ( __DEV__ ) {
129
- warn ( 'Invalid template ref type:' , ref , `(${ typeof ref } )` )
134
+ // warn('Invalid template ref type:', ref, `(${typeof ref})`)
130
135
}
131
136
}
132
137
return ref
0 commit comments