hast-util-has-property is a focused utility within the unified (specifically HAST) ecosystem, designed to ascertain if a given HAST (Hypertext Abstract Syntax Tree) element node possesses a specified property. The current stable version is 3.0.0. This package is maintained by the syntax-tree collective, aligning its release cadence with Node.js LTS versions and the broader `unified` project's evolution, frequently releasing new major versions to adopt modern JavaScript features like ESM. Its primary differentiation lies in its tight integration with the HAST specification, providing a type-safe (TypeScript-enabled) and robust method for property checking, crucial for HTML processing pipelines. It is a highly specialized tool, typically used by developers working directly with HAST manipulation, offering a reliable primitive for conditional logic based on element properties in transform plugins. It strictly operates on valid HAST `Node` objects, particularly `Element` types, providing a precise `boolean` result.
npm install hast-util-has-propertyVerified import paths — ran on the pinned version, not inferred.
Demonstrates how to import and use the `hasProperty` function to check for the existence of properties on different HAST nodes.
Upgrade your Node.js environment to version 16 or higher. For projects that cannot upgrade, consider pinning to `hast-util-has-property@2`.
Migrate your project to use ECMAScript Modules (ESM) syntax (`import ... from '...'`) for this package. Ensure your `package.json` specifies `"type": "module"` or use `.mjs` file extensions.
Ensure that the `node` argument passed to `hasProperty` is a valid HAST `Node` (typically an `Element`), and the `field` argument is a string representing the property name. Avoid passing `null`, `undefined`, or other non-node values.
Always use named imports: `import { hasProperty } from 'hast-util-has-property'`. Do not use `import hasProperty from 'hast-util-has-property'`.Change `const hasProperty = require('hast-util-has-property')` to `import { hasProperty } from 'hast-util-has-property'`. Ensure your project is configured for ESM (e.g., `"type": "module"` in `package.json`).Use the correct named import: `import { hasProperty } from 'hast-util-has-property'`. Verify that no default import syntax is used.Ensure that the `node` argument supplied to `hasProperty` is always a well-formed HAST `Node` object, as expected by the utility.
No dependency data recorded yet.