@f/apply-styles

Apply a style object to a DOM node

Stats

StarsIssuesVersionUpdatedCreatedSize
@f/apply-styles
001.0.65 years ago6 years agoMinified + gzip package size for @f/apply-styles in KB

Readme

apply-styles

Build status Git tag NPM version Code style

Apply a style object to a DOM node, optionally diffing against a previous set of styles.

Installation

$ npm install @f/apply-styles

Usage

var applyStyles = require('@f/apply-styles')

function setAttribute (node, name, value, prevValue) {
  if (name === 'style') {
    applyStyles(node, value, prevValue)
  }

  // ...set other kinds of attributes...
}

API

applyStyles(node, styles, prevStyles)

  • node - The DOM node to apply the styles to
  • styles - The styles you want to set
  • prevStyles - Optional, a previous style object to diff against (i.e. remove props that are not set in the current style)

Returns: void

License

MIT

If you find any bugs or have a feature request, please open an issue on github!

The npm package download data comes from npm's download counts api and package details come from npms.io.