JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 3379407
  • Score
    100M100P100Q222582F
  • License MIT

Check if a node is a (certain) element

Package Exports

  • hast-util-is-element

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (hast-util-is-element) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

hast-util-is-element Build Coverage Downloads Chat

Check if a node is a (certain) HAST element.

Installation

npm:

npm install hast-util-is-element

Usage

var is = require('hast-util-is-element')

is({type: 'text', value: 'foo'}) // => false

is({type: 'element', tagName: 'a'}, 'a') // => true

is({type: 'element', tagName: 'a'}, ['a', 'area']) // => true

API

isElement(node[, tagName|tagNames])

Check if a node is a (certain) HAST element.

When not given a second parameter, asserts if node is an element, otherwise asserts node is an element whose tagName matches / is included in the second parameter.

Parameters
  • node (*) — Value to check;
  • tagName (string, optional) — Value nodes tagName must match;
  • tagNames (Array.<string>, optional) — Value including nodes tagName.
Returns

boolean — whether node passes the test.

Throws

Error — When the second parameter is given but invalid.

Contribute

See contributing.md in syntax-tree/hast for ways to get started.

This organisation has a Code of Conduct. By interacting with this repository, organisation, or community you agree to abide by its terms.

License

MIT © Titus Wormer