mirror of
https://github.com/robonen/tools.git
synced 2026-03-20 10:54:44 +00:00
docs(web/vue): update documentation for unrefElement function
This commit is contained in:
@@ -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;
|
||||||
|
|||||||
Reference in New Issue
Block a user