Skip to main content

Function: hasDom()

hasDom(): boolean

Defined in: packages/sdvplot/src/interact/highlight.ts:28

Interaction needs a live DOM. Without one (Node / SSR) every sdvplot/interact function is a no-op, so a server-rendered figure is byte-identical with or without a link.

Returns​

boolean

Example​

import { hasDom } from "@sportsdataverse/sdvplot/interact";

// it depends on where this runs: a browser (or the jsdom that prerendered this page) has a DOM, Node has none
`this ran ${hasDom() ? "with a DOM: interact functions work" : "without a DOM: interact functions are no-ops"}`;