mirror of
https://gitee.com/element-plus/element-plus.git
synced 2024-12-15 18:01:24 +08:00
5e68255e11
- Fix circular referencing in refs.ts
22 lines
534 B
TypeScript
22 lines
534 B
TypeScript
import { isFunction } from '../types'
|
|
|
|
import type { ComponentPublicInstance, Ref } from 'vue'
|
|
|
|
export type RefSetter = (
|
|
el: Element | ComponentPublicInstance | undefined
|
|
) => void
|
|
|
|
export const composeRefs = (
|
|
...refs: (Ref<HTMLElement | undefined> | RefSetter)[]
|
|
) => {
|
|
return (el: Element | ComponentPublicInstance | null) => {
|
|
refs.forEach((ref) => {
|
|
if (isFunction(ref)) {
|
|
ref(el as Element | ComponentPublicInstance)
|
|
} else {
|
|
ref.value = el as HTMLElement | undefined
|
|
}
|
|
})
|
|
}
|
|
}
|