Code coverage report for 6to5/generation/generators/jsx.js

Statements: 24.07% (13 / 54)      Branches: 0% (0 / 16)      Functions: 9.09% (1 / 11)      Lines: 24.53% (13 / 53)      Ignored: none     

All files » 6to5/generation/generators/ » jsx.js
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 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 831 1   1               1       1           1           1           1           1                                               1                   1           1 1    
var t = require("../../types");
var _ = require("lodash");
 
exports.XJSAttribute = function (node, print) {
  print(node.name);
  if (node.value) {
    this.push("=");
    print(node.value);
  }
};
 
exports.XJSIdentifier = function (node) {
  this.push(node.name);
};
 
exports.XJSNamespacedName = function (node, print) {
  print(node.namespace);
  this.push(":");
  print(node.name);
};
 
exports.XJSMemberExpression = function (node, print) {
  print(node.object);
  this.push(".");
  print(node.property);
};
 
exports.XJSSpreadAttribute = function (node, print) {
  this.push("{...");
  print(node.argument);
  this.push("}");
};
 
exports.XJSExpressionContainer = function (node, print) {
  this.push("{");
  print(node.expression);
  this.push("}");
};
 
exports.XJSElement = function (node, print) {
  var self = this;
 
  var open = node.openingElement;
  print(open);
  if (open.selfClosing) return;
 
  this.indent();
  _.each(node.children, function (child) {
    if (t.isLiteral(child) && typeof child.value === "string") {
      if (/\S/.test(child.value)) {
        return self.push(child.value.replace(/^\s+|\s+$/g, ""));
      } else if (/\n/.test(child.value)) {
        return self.newline();
      }
    }
 
    print(child);
  });
  this.dedent();
 
  print(node.closingElement);
};
 
exports.XJSOpeningElement = function (node, print) {
  this.push("<");
  print(node.name);
  if (node.attributes.length > 0) {
    this.space();
    print.join(node.attributes, { separator: " " });
  }
  this.push(node.selfClosing ? " />" : ">");
};
 
exports.XJSClosingElement = function (node, print) {
  this.push("</");
  print(node.name);
  this.push(">");
};
 
exports.XJSEmptyExpression = function () {
  this.push("null");
};