1.0.6 • Published 8 years ago
@f/apply-styles v1.0.6
apply-styles
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 tostyles
- The styles you want to setprevStyles
- Optional, a previous style object to diff against (i.e. remove props that are not set in the currentstyle
)
Returns: void
License
MIT