hast-util-is-element
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
tagNameortagNames, checks thatnodeis an element whosetagNamefield matchestagNameor is included intagNames - Otherwise checks that
nodeis an element
Parameters
node(*) — Value to check, probablyNodetagName(string, optional) — Value thatnodestagNamefield should matchtagNames(Array.<string>, optional) — Values that should includenodestagNamefield 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.