refElement

Commons
stable

Extract the underlying HTMLElement from a Vue component instance or a raw HTMLElement ref. Handles multi-root components by following the first element sibling of a text node.

API

Signature

Full TypeScript signature sourced from the util file.

typescript

API

Parameters

Input parameters accepted by this util.

obj
ComponentPublicInstance<any> | HTMLElement
A Vue component instance (has $el), a raw HTMLElement, or undefined. Returns undefined when the argument is absent or the element cannot be resolved.

API

Return value

The value returned by this util.

The resolved HTMLElement, or undefined when the argument is undefined or resolves to a non-element node.

Usage

Examples

Ready-to-paste usage snippets.

Resolve an element from a component ref

typescript