@f/is-valid-attr

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

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
@f/is-valid-attr
001.0.07 years ago7 years agoMinified + gzip package size for @f/is-valid-attr in KB

Readme

is-valid-attr
!Build statustravis-imagetravis-url !Git taggit-imagegit-url !NPM versionnpm-imagenpm-url !Code stylestandard-imagestandard-url
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