JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 3353007
  • Score
    100M100P100Q222665F
  • 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 Size Sponsors Backers Chat

hast utility to check if a node is a (certain) element.

Install

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 the given value is a (certain) element.

  • When given a tagName or tagNames, checks that node is an element whose tagName field matches tagName or is included in tagNames
  • Otherwise checks that node is an element
Parameters
  • node (*) — Value to check, probably Node
  • tagName (string, optional) — Value that nodes tagName field should match
  • tagNames (Array.<string>, optional) — Values that should include nodes tagName field should match
Returns

boolean — whether node passes the test.

Throws

Error — When the second parameter is given but invalid.

Contribute

See contributing.md in syntax-tree/.github for ways to get started. See support.md for ways to get help.

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

License

MIT © Titus Wormer