hast-util-from-selector is a utility package within the unified ecosystem designed to parse CSS selectors and generate corresponding HAST (Hypertext Abstract Syntax Tree) element nodes. It is currently at version 3.0.1, supporting Node.js 16 and later, and adheres to an ESM-only distribution model. The project follows a release cadence tied to Node.js LTS versions, with major versions introducing breaking changes aligned with Node.js support lifecycles or significant internal architectural shifts, such as the move to ESM in v2 and Node.js 16 requirement in v3. This package distinguishes itself from `hast-util-parse-selector` by offering more powerful and complex selector parsing capabilities, akin to `hastscript` but specifically focused on creating HAST elements from selector strings rather than a full hyperscript API. It's an active project, receiving regular updates for dependencies and type refinements.
npm install hast-util-from-selectorVerified import paths — ran on the pinned version, not inferred.
Demonstrates parsing a complex CSS selector string into a HAST element tree.
Upgrade your Node.js environment to version 16 or newer.
Update your import statements to use ES Modules syntax: `import { fromSelector } from 'hast-util-from-selector'`.Change `fromSelector(selector, 'svg')` to `fromSelector(selector, { space: 'svg' })`.Review and test any complex or unusual CSS selectors to ensure they parse as expected under the CSS Selectors Level 4 specification.
Always sanitize or validate any user-provided or external CSS selector strings before passing them to `fromSelector` to prevent XSS attacks.
Update your import statements to use ES Modules syntax: `import { fromSelector } from 'hast-util-from-selector'`.Ensure your Node.js environment is version 16 or higher. If using a bundler (e.g., Webpack, Rollup), ensure it's configured to handle ESM packages correctly.
Verify that you are using a named import: `import { fromSelector } from 'hast-util-from-selector'`, as the package has no default export.Refer to the CSS Selectors Level 4 specification and the package's documentation for supported selector types. Simplify your selector or use a different method to construct complex HAST nodes.
No dependency data recorded yet.