Vize

element-target

Whether a value is a DOM element node.

Package @vizejs/composable/element-target
Own the source vize lib pull composable:element-target
Runtime exports isElementNode, resolveElement, resolveElements
Gzip budget 1024 B

Usage

import { isElementNode, resolveElement, resolveElements } from "@vizejs/composable/element-target";

Runtime contract

Utility Category Stability SSR Hydration Cleanup Targets Host globals Uses
isElementNode dom experimental safe not-applicable none web, server, worker, native, desktop, terminal — —
resolveElement dom experimental safe not-applicable none web, server, worker, native, desktop, terminal — isElementNode
resolveElements dom experimental safe not-applicable none web, server, worker, native, desktop, terminal — isElementNode

API

isElementNode

Whether a value is a DOM element node. Uses the nodeType contract instead of instanceof Element, so the check reads no browser globals and works across realms (iframes, happy-dom, jsdom).

function isElementNode(value: unknown): value is Element

resolveElement

Resolve a reactive element target to its concrete element. Reads the reactive source once (tracking it when called inside an effect). Component instances resolve to their root element; fragment or text roots resolve to null. Never throws and reads no browser globals, so it is safe during server rendering, where it always returns null.

function resolveElement(target: MaybeElementTarget): Element | null

resolveElements

Resolve a reactive list (or single) element target to its concrete elements. Unresolved entries are dropped and duplicates are removed while keeping the first-seen order, so observers never register the same node twice.

function resolveElements(targets: MaybeElementTargets): Element[]