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

Check if a node is a (certain) HAST element.
Installation
npm:
npm install hast-util-is-element
hast-util-is-element is also available as an AMD, CommonJS, and globals module, uncompressed and compressed.
Usage
Dependencies:
var isElement = require('hast-util-is-element');
Given a non-element:
var result = isElement({
'type': 'text',
'value': 'foo'
});
Yields:
false
Given a matching element:
result = isElement({
'type': 'element',
'tagName': 'a'
}, 'a');
Yields:
true
Given multiple tagNames:
result = isElement({
'type': 'element',
'tagName': 'a'
}, ['a', 'area']);
Yields:
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) — Valuenode
stagName
must match;tagNames
(string
, optional) — Value includingnode
stagName
.
Returns: boolean
, whether node
passes the test.
Throws: when the second parameter is given but invalid.