Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@f/is-valid-attr

micro-js2MIT1.0.0

Check whether or not a value is a valid attribute of a DOM element

readme

is-valid-attr

Build status Git tag NPM version Code style

Check whether or not a value is a valid DOM attribute

Installation

$ npm install @f/is-valid-attr

Usage

var isValidAttr = require('@f/is-valid-attr')

function setAttribute (node, name, value) {
  if (isValidAttr(value)) {
    node.setAttribute(name, value)
  }
}

API

isValidAttr(value)

  • value - The value who's validity you want to check

Returns: Boolean indicating whether or not the value can be set as an attribute of a DOM element

License

MIT