diff --git a/lib/6to5/generation/generators/jsx.js b/lib/6to5/generation/generators/jsx.js index d372cbc74b..15bf937e16 100644 --- a/lib/6to5/generation/generators/jsx.js +++ b/lib/6to5/generation/generators/jsx.js @@ -3,7 +3,7 @@ var t = require("../../types"); var _ = require("lodash"); -exports.XJSAttribute = function (node, print) { +exports.JSXAttribute = function (node, print) { print(node.name); if (node.value) { this.push("="); @@ -11,35 +11,35 @@ exports.XJSAttribute = function (node, print) { } }; -exports.XJSIdentifier = function (node) { +exports.JSXIdentifier = function (node) { this.push(node.name); }; -exports.XJSNamespacedName = function (node, print) { +exports.JSXNamespacedName = function (node, print) { print(node.namespace); this.push(":"); print(node.name); }; -exports.XJSMemberExpression = function (node, print) { +exports.JSXMemberExpression = function (node, print) { print(node.object); this.push("."); print(node.property); }; -exports.XJSSpreadAttribute = function (node, print) { +exports.JSXSpreadAttribute = function (node, print) { this.push("{..."); print(node.argument); this.push("}"); }; -exports.XJSExpressionContainer = function (node, print) { +exports.JSXExpressionContainer = function (node, print) { this.push("{"); print(node.expression); this.push("}"); }; -exports.XJSElement = function (node, print) { +exports.JSXElement = function (node, print) { var self = this; var open = node.openingElement; @@ -59,7 +59,7 @@ exports.XJSElement = function (node, print) { print(node.closingElement); }; -exports.XJSOpeningElement = function (node, print) { +exports.JSXOpeningElement = function (node, print) { this.push("<"); print(node.name); if (node.attributes.length > 0) { @@ -69,12 +69,12 @@ exports.XJSOpeningElement = function (node, print) { this.push(node.selfClosing ? " />" : ">"); }; -exports.XJSClosingElement = function (node, print) { +exports.JSXClosingElement = function (node, print) { this.push(""); }; -exports.XJSEmptyExpression = function () { +exports.JSXEmptyExpression = function () { }; diff --git a/lib/6to5/transformation/transformers/other/react.js b/lib/6to5/transformation/transformers/other/react.js index 5d1e8fec6e..9482f7e633 100644 --- a/lib/6to5/transformation/transformers/other/react.js +++ b/lib/6to5/transformation/transformers/other/react.js @@ -9,7 +9,7 @@ var esutils = require("esutils"); var t = require("../../../types"); var _ = require("lodash"); -exports.XJSIdentifier = function (node) { +exports.JSXIdentifier = function (node) { if (esutils.keyword.isIdentifierName(node.name)) { node.type = "Identifier"; } else { @@ -17,22 +17,22 @@ exports.XJSIdentifier = function (node) { } }; -exports.XJSNamespacedName = function (node, parent, scope, context, file) { +exports.JSXNamespacedName = function (node, parent, scope, context, file) { throw file.errorWithNode(node, "Namespace tags are not supported. ReactJSX is not XML."); }; -exports.XJSMemberExpression = { +exports.JSXMemberExpression = { exit: function (node) { node.computed = t.isLiteral(node.property); node.type = "MemberExpression"; } }; -exports.XJSExpressionContainer = function (node) { +exports.JSXExpressionContainer = function (node) { return node.expression; }; -exports.XJSAttribute = { +exports.JSXAttribute = { exit: function (node) { var value = node.value || t.literal(true); return t.inherits(t.property("init", node.name, value), node); @@ -43,7 +43,7 @@ var isCompatTag = function (tagName) { return /^[a-z]|\-/.test(tagName); }; -exports.XJSOpeningElement = { +exports.JSXOpeningElement = { exit: function (node, parent, scope, context, file) { var reactCompat = file.opts.reactCompat; var tagExpr = node.name; @@ -66,7 +66,7 @@ exports.XJSOpeningElement = { var attribs = node.attributes; if (attribs.length) { - attribs = buildXJSOpeningElementAttributes(attribs); + attribs = buildJSXOpeningElementAttributes(attribs); } else { attribs = t.literal(null); } @@ -99,7 +99,7 @@ exports.XJSOpeningElement = { * all prior attributes to an array for later processing. */ -var buildXJSOpeningElementAttributes = function (attribs) { +var buildJSXOpeningElementAttributes = function (attribs) { var _props = []; var objs = []; @@ -112,7 +112,7 @@ var buildXJSOpeningElementAttributes = function (attribs) { while (attribs.length) { var prop = attribs.shift(); - if (t.isXJSSpreadAttribute(prop)) { + if (t.isJSXSpreadAttribute(prop)) { pushProps(); objs.push(prop.argument); } else { @@ -141,7 +141,7 @@ var buildXJSOpeningElementAttributes = function (attribs) { return attribs; }; -exports.XJSElement = { +exports.JSXElement = { exit: function (node) { var callExpr = node.openingElement; @@ -149,9 +149,9 @@ exports.XJSElement = { var child = node.children[i]; if (t.isLiteral(child) && _.isString(child.value)) { - cleanXJSElementLiteralChild(child, callExpr.arguments); + cleanJSXElementLiteralChild(child, callExpr.arguments); continue; - } else if (t.isXJSEmptyExpression(child)) { + } else if (t.isJSXEmptyExpression(child)) { continue; } @@ -166,7 +166,7 @@ exports.XJSElement = { } }; -var cleanXJSElementLiteralChild = function (child, args) { +var cleanJSXElementLiteralChild = function (child, args) { var lines = child.value.split(/\r\n|\n|\r/); for (var i = 0; i < lines.length; i++) { diff --git a/lib/6to5/types/alias-keys.json b/lib/6to5/types/alias-keys.json index cc80d7290c..063f0670da 100644 --- a/lib/6to5/types/alias-keys.json +++ b/lib/6to5/types/alias-keys.json @@ -45,7 +45,7 @@ "AssignmentPattern": ["Pattern"], "Property": ["UserWhitespacable"], - "XJSElement": ["UserWhitespacable", "Expression"], + "JSXElement": ["UserWhitespacable", "Expression"], "ArrayExpression": ["Expression"], "AssignmentExpression": ["Expression"], @@ -65,7 +65,7 @@ "ThisExpression": ["Expression"], "UpdateExpression": ["Expression"], "VirtualPropertyExpression": ["Expression"], - "XJSEmptyExpression": ["Expression"], - "XJSMemberExpression": ["Expression"], + "JSXEmptyExpression": ["Expression"], + "JSXMemberExpression": ["Expression"], "YieldExpression": ["Expression"] } diff --git a/lib/6to5/types/visitor-keys.json b/lib/6to5/types/visitor-keys.json index 125e91c922..c5abe7141f 100644 --- a/lib/6to5/types/visitor-keys.json +++ b/lib/6to5/types/visitor-keys.json @@ -101,14 +101,14 @@ "UnionTypeAnnotation": [], "VoidTypeAnnotation": [], - "XJSAttribute": ["name", "value"], - "XJSClosingElement": ["name"], - "XJSElement": ["openingElement", "closingElement", "children"], - "XJSEmptyExpression": [], - "XJSExpressionContainer": ["expression"], - "XJSIdentifier": [], - "XJSMemberExpression": ["object", "property"], - "XJSNamespacedName": ["namespace", "name"], - "XJSOpeningElement": ["name", "attributes"], - "XJSSpreadAttribute": ["argument"] + "JSXAttribute": ["name", "value"], + "JSXClosingElement": ["name"], + "JSXElement": ["openingElement", "closingElement", "children"], + "JSXEmptyExpression": [], + "JSXExpressionContainer": ["expression"], + "JSXIdentifier": [], + "JSXMemberExpression": ["object", "property"], + "JSXNamespacedName": ["namespace", "name"], + "JSXOpeningElement": ["name", "attributes"], + "JSXSpreadAttribute": ["argument"] }