const { map, isFunction } = require("lodash/fp");
const { hasOwn } = require("../util");

const transformAttrKey = require("./transform-attr-key");
const { renderStyleAttribute } = require("./style");

const mapWithKey = map.convert({ cap: false });


const attrsNotToRender = {
  children: true,
  dangerouslySetInnerHTML: true
};

/**
 * Render an object of key/value pairs into their HTML attribute equivalent.
 *
 * @param      {Object}  attrs   Attributes in object form.
 *
 * @return     {String}          Generated HTML attribute output.
 */
function renderAttrs (attrs) {
  const attrString = [];

  for (let attrKey in attrs) {
    if (
      hasOwn(attrs, attrKey) &&
      !attrsNotToRender[attrKey]
    ) {
      let attrVal = attrs[attrKey];

      if (!attrVal || isFunction(attrVal)) { continue; }

      attrKey = transformAttrKey(attrKey);

      if (attrVal === true) {
        attrVal = "";
      } else if (attrKey === "style" && typeof attrVal === "object") {
        attrVal = `="${renderStyleAttribute(attrVal)}"`;
      } else {
        attrVal = `="${attrVal}"`;
      }

      attrString.push(` ${attrKey}${attrVal}`);
    }
  }

  return attrString.join("");
}

const mapPairToString = mapWithKey((val, key) => `${key}:${key}`);
function styleObjToString (obj) {
  return mapPairToString(obj).join(";");
}


module.exports = renderAttrs;

@@ -4,13 +4,8 @@
 st %7B
- map,
  isF
@@ -194,58 +194,8 @@
 );%0A%0A
-const mapWithKey = map.convert(%7B cap: false %7D);%0A%0A%0A
 cons
@@ -1132,154 +1132,8 @@
 %0A%7D%0A%0A
-const mapPairToString = mapWithKey((val, key) =%3E %60$%7Bkey%7D:$%7Bkey%7D%60);%0Afunction styleObjToString (obj) %7B%0A  return mapPairToString(obj).join(%22;%22);%0A%7D%0A%0A%0A
 modu

Remove old style parsing implementation