_getElementAttribute: function()

in src/htmltojsx.js [613:636]


  _getElementAttribute: function(node, attribute) {
    switch (attribute.name) {
      case 'style':
        return this._getStyleAttribute(attribute.value);
      default:
        var tagName = jsxTagName(node.tagName);
        var name =
          (ELEMENT_ATTRIBUTE_MAPPING[tagName] &&
            ELEMENT_ATTRIBUTE_MAPPING[tagName][attribute.name]) ||
          ATTRIBUTE_MAPPING[attribute.name] ||
          attribute.name;
        var result = name;

        // Numeric values should be output as {123} not "123"
        if (isNumeric(attribute.value)) {
          result += '={' + attribute.value + '}';
        } else if (attribute.value.length > 0) {
          result += '="' + attribute.value.replace(/"/gm, '"') + '"';
        } else if(attribute.value.length === 0 && attribute.name === 'alt') {
          result += '=""';
        }
        return result;
    }
  },