1
0
mirror of https://github.com/robonen/tools.git synced 2026-03-20 02:44:45 +00:00

docs(web/vue): update documentation for unrefElement function

This commit is contained in:
2025-08-15 04:37:58 +07:00
parent 1851d5c80c
commit e035d1abca

View File

@@ -9,6 +9,24 @@ export type MaybeComputedElementRef<El extends MaybeElement = MaybeElement> = Ma
export type UnRefElementReturn<T extends MaybeElement = MaybeElement> = T extends VueInstance ? Exclude<MaybeElement, VueInstance> : T | undefined; export type UnRefElementReturn<T extends MaybeElement = MaybeElement> = T extends VueInstance ? Exclude<MaybeElement, VueInstance> : T | undefined;
/**
* @name unrefElement
* @category Components
* @description Unwraps a Vue element reference to get the underlying instance or DOM element.
*
* @param {MaybeComputedElementRef<El>} elRef - The element reference to unwrap.
* @returns {UnRefElementReturn<El>} - The unwrapped element or undefined.
*
* @example
* const element = useTemplateRef('element');
* const result = unrefElement(element); // result is the element instance
*
* @example
* const component = useTemplateRef('component');
* const result = unrefElement(component); // result is the component instance
*
* @since 0.0.11
*/
export function unrefElement<El extends MaybeElement>(elRef: MaybeComputedElementRef<El>): UnRefElementReturn<El> { export function unrefElement<El extends MaybeElement>(elRef: MaybeComputedElementRef<El>): UnRefElementReturn<El> {
const plain = toValue(elRef); const plain = toValue(elRef);
return (plain as VueInstance)?.$el ?? plain; return (plain as VueInstance)?.$el ?? plain;