unified

Project: syntax-tree/hast-util-is-element

Package: hast-util-is-element@1.0.4

  1. Dependencies: 0·Dependents: 53
  2. hast utility to check if a node is a (certain) element
  1. util 105
  2. utility 103
  3. html 102
  4. unist 93
  5. hast 55
  6. hast-util 38
  7. element 5
  8. is 3

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

Use

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.

Parameters
Returns

boolean — whether node passes the test.

Throws

Error — When the second parameter is given but invalid.

Security

hast-util-is-element does not change the syntax tree so there are no openings for cross-site scripting (XSS) attacks.

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, organization, or community you agree to abide by its terms.

License

MIT © Titus Wormer