unified

Project: syntax-tree/hast-util-labelable

Package: hast-util-labelable@2.0.0

  1. Dependencies: 0·Dependents: 0
  2. hast utility to check whether a node is labelable
  1. util 129
  2. utility 125
  3. unist 119
  4. html 111
  5. hast 60
  6. hast-util 40

hast-util-labelable

Build Coverage Downloads Size Sponsors Backers Chat

hast utility to check if an element is labelable.

Install

This package is ESM only: Node 12+ is needed to use it and it must be imported instead of required.

npm:

npm install hast-util-labelable

Use

import {labelable} from '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

This package exports the following identifiers: labelable. There is no default export.

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