Skip to content

syntax-tree/hast-util-labelable

Repository files navigation

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

Usage

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
  • node (*, optional) — Value to check, probably Node
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, organisation, or community you agree to abide by its terms.

License

MIT © Titus Wormer

About

utility to check whether a node is labelable

Topics

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Contributors 3

  •  
  •  
  •