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

Statements: 100% (50 / 50)      Branches: 100% (10 / 10)      Functions: 100% (11 / 11)      Lines: 100% (49 / 49)      Ignored: none     

All files » 6to5/lib/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 791 1   1 6 6 4 4       1 29     1 1 1 1     1 1 1 1     1 1 1 1     1 2 2 2     1 12   12 12 12   9 9 5 3   2     9   9     1 12 12 12 5 5   12     1 9 9 9     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)) {
      self.push(child.value);
    } else {
      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 () {
 
};