hast-util-is-element
hast utility to check if a node is a (certain) element
Last updated 6 years ago by wooorm .
MIT · Repository · Bugs · Original npm
$ cnpm install hast-util-is-element 
SYNC missed versions from official npm registry.

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.

  • 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.

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

Current Tags

  • 2.1.3                                ...           latest (3 years ago)

5 Versions

  • 2.1.3                                ...           3 years ago
  • 2.1.2                                ...           4 years ago
  • 2.1.1                                ...           4 years ago
  • 1.1.0                                ...           5 years ago
  • 1.0.4                                ...           6 years ago
Maintainers (2)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (0)
None
Dev Dependencies (8)
Dependents (0)
None

Copyright 2013 - present © cnpmjs.org