hast-util-interactive is a focused utility within the unified ecosystem, specifically designed to determine if a given hast (Hypertext Abstract Syntax Tree) node constitutes "interactive content" according to the HTML specification. This package is particularly useful for tools that analyze or transform HTML content and need to identify elements like `<a>` with `href`, `<button>`, `<input>`, or `<video controls>` to enforce accessibility rules, validate content, or apply specific styling. The current stable version is 3.0.0. Maintained by the syntax-tree collective, it follows a release cadence tied to Node.js LTS cycles and hast ecosystem updates, providing TypeScript types for enhanced developer experience. Its primary differentiator is its precise implementation of the HTML interactive content algorithm for hast nodes, offering a reliable predicate function rather than a full parsing or transformation engine.
npm install hast-util-interactiveVerified import paths — ran on the pinned version, not inferred.
Demonstrates how to use the `interactive` function to check various hast nodes against the HTML specification for interactive content.
Upgrade your Node.js environment to version 16 or newer. For projects requiring older Node.js, use `hast-util-interactive@^2`.
Ensure that the `node` argument passed to `interactive()` is always a valid `hast` Node object. Validate input before calling the utility.
Always import symbols directly from the package's main entry point, e.g., `import { interactive } from 'hast-util-interactive'`. Do not try to access internal paths like `hast-util-interactive/lib/interactive.js`.Update your import statements to use ES module syntax (e.g., `import { interactive } from 'hast-util-interactive'`). Ensure your project is configured for ESM, or use a tool like Babel/TypeScript to transpile.Understand the HTML specification for interactive content before use. This utility serves a niche purpose within the unified ecosystem.
Change your import statement from `const { interactive } = require('hast-util-interactive')` to `import { interactive } from 'hast-util-interactive'` and ensure your Node.js environment or build setup supports ESM.Upgrade your Node.js environment to version 16 or higher. Alternatively, ensure the `import` statement is correct and the module is resolving properly.
Before calling `interactive(node)`, validate that `node` is indeed a `hast` Node object. For example, `if (node && typeof node === 'object' && node.type) { interactive(node) }`.No dependency data recorded yet.