all files / elementx/ index.js

100% Statements 11/11
100% Branches 5/5
100% Functions 3/3
100% Lines 11/11
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26    19×           11×                
 
var hyphenate = require('@f/hyphenate')
var decorate = require('./decorate')
var cn = require('classnames')
 
module.exports = decorate(function (key, value) {
  switch (key) {
    case 'class':
      return cn(value)
    case 'style':
      return typeof value !== 'string'
        ? toInlineStyle(value)
        : value
    default:
      return value
  }
})
 
function toInlineStyle (def) {
  return Object.keys(def)
    .map(function (prop) {
      return hyphenate(prop) + ':' + def[prop]
    })
    .join(';')
}