unified

Project: syntax-tree/hast-util-labelable

Package: hast-util-labelable@1.0.4

  1. Dependencies: 0·Dependents: 0
  2. hast utility to check whether a node is labelable
  1. util 107
  2. html 106
  3. utility 105
  4. unist 97
  5. hast 59
  6. hast-util 40

hast-util-labelable

Build Coverage Downloads Size Sponsors Backers Chat

hast utility to check if an element is labelable.

Install

npm:

npm install hast-util-labelable

Use

var labelable = require('hast-util-labelable')

labelable({type: 'element', tagName: 'div'}) // => false

labelable({type: 'element', tagName: 'input'}) // => true

labelable({
  type: 'element',
  tagName: 'input',
  properties: {type: 'hidden'}
}) // => false

API

labelable(node)

Check if the given value is a labelable element.

Parameters
Returns

boolean — Whether node is a labelable element. Labelable nodes have a tagName set to button, keygen, meter, output, progress, select, textarea, and input (excluding [type=hidden]).

Security

hast-util-labelable 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