Compare commits
18 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7f3959444c | ||
|
|
0ba9216d6f | ||
|
|
6dfe66bce3 | ||
|
|
9e08a6f084 | ||
|
|
b9f3f1e2a9 | ||
|
|
4f18ed406c | ||
|
|
4d8e5f728a | ||
|
|
54857ceac7 | ||
|
|
5b961ea3e7 | ||
|
|
35b28cf722 | ||
|
|
c5bfbf37f0 | ||
|
|
cfee68aa67 | ||
|
|
7d0dae129c | ||
|
|
f9d14fa2ed | ||
|
|
11d55e661e | ||
|
|
0544e98fb1 | ||
|
|
59d918ea67 | ||
|
|
b4232699d2 |
14
CHANGELOG.md
14
CHANGELOG.md
@@ -1,3 +1,17 @@
|
||||
# 1.12.0
|
||||
|
||||
* Combine `jsx` and `react` transformers to `react`.
|
||||
* Update `react` syntax output to React v0.12.
|
||||
|
||||
# 1.11.15
|
||||
|
||||
* Fix JSX literal whitespace generation.
|
||||
|
||||
# 1.11.14
|
||||
|
||||
* Avoid using a switch for let-scoping continue and break statements and use an if statement instead.
|
||||
* Remove excess whitespace and newlines from JSX literals.
|
||||
|
||||
# 1.11.13
|
||||
|
||||
* Update regenerator-6to5
|
||||
|
||||
@@ -146,7 +146,7 @@ File.prototype.generate = function () {
|
||||
|
||||
if (this.shebang) {
|
||||
// add back shebang
|
||||
result.code = this.shebang + result.code;
|
||||
result.code = this.shebang + "\n" + result.code;
|
||||
}
|
||||
|
||||
if (opts.sourceMap === "inline") {
|
||||
|
||||
@@ -46,15 +46,11 @@ exports.XJSElement = function (node, print) {
|
||||
|
||||
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();
|
||||
}
|
||||
if (t.isLiteral(child)) {
|
||||
self.push(child.value);
|
||||
} else {
|
||||
print(child);
|
||||
}
|
||||
|
||||
print(child);
|
||||
});
|
||||
this.dedent();
|
||||
|
||||
|
||||
@@ -80,6 +80,10 @@ Node.prototype.needsWhitespace = function (type) {
|
||||
if (t.isProperty(node) && parent.properties[0] === node) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (t.isSwitchCase(node) && parent.cases[0] === node) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (type === "after") {
|
||||
|
||||
@@ -49,7 +49,6 @@ _.each({
|
||||
numericLiterals: require("./transformers/numeric-literals"),
|
||||
|
||||
react: require("./transformers/react"),
|
||||
jsx: require("./transformers/jsx"),
|
||||
|
||||
_aliasFunctions: require("./transformers/_alias-functions"),
|
||||
_blockHoist: require("./transformers/_block-hoist"),
|
||||
|
||||
@@ -1,89 +0,0 @@
|
||||
// Based upon the excellent jsx-transpiler by Ingvar Stepanyan (RReverser)
|
||||
// https://github.com/RReverser/jsx-transpiler
|
||||
|
||||
var esutils = require("esutils");
|
||||
var t = require("../../types");
|
||||
var _ = require("lodash");
|
||||
|
||||
var JSX_ANNOTATION_REGEX = /^\*\s*@jsx\s+([^\s]+)/;
|
||||
|
||||
exports.Program = function (node, parent, file) {
|
||||
var jsx = "React.DOM";
|
||||
|
||||
// looking for namespace annotation
|
||||
_.each(node.leadingComments, function (comment) {
|
||||
var matches = JSX_ANNOTATION_REGEX.exec(comment.value);
|
||||
if (matches) jsx = matches[1];
|
||||
});
|
||||
|
||||
// prebuilding AST node
|
||||
file.jsx = jsx.split(".").map(t.identifier).reduce(function (object, property) {
|
||||
return t.memberExpression(object, property);
|
||||
});
|
||||
};
|
||||
|
||||
exports.XJSIdentifier = function (node) {
|
||||
if (esutils.keyword.isIdentifierName(node.name)) {
|
||||
node.type = "Identifier";
|
||||
} else {
|
||||
return t.literal(node.name);
|
||||
}
|
||||
};
|
||||
|
||||
exports.XJSNamespacedName = function () {
|
||||
throw new Error("Namespace tags are not supported. ReactJSX is not XML.");
|
||||
};
|
||||
|
||||
exports.XJSMemberExpression = {
|
||||
exit: function (node) {
|
||||
node.computed = t.isLiteral(node.property);
|
||||
node.type = "MemberExpression";
|
||||
}
|
||||
};
|
||||
|
||||
exports.XJSExpressionContainer = function (node) {
|
||||
return node.expression;
|
||||
};
|
||||
|
||||
exports.XJSAttribute = {
|
||||
exit: function (node) {
|
||||
var value = node.value || t.literal(true);
|
||||
return t.property("init", node.name, value);
|
||||
}
|
||||
};
|
||||
|
||||
exports.XJSOpeningElement = {
|
||||
exit: function (node, parent, file) {
|
||||
var tagExpr = node.name;
|
||||
|
||||
if (t.isIdentifier(tagExpr)) {
|
||||
var tagName = tagExpr.name;
|
||||
|
||||
if (/[a-z]/.exec(tagName[0]) || _.contains(tagName, "-")) {
|
||||
tagExpr = t.memberExpression(file.jsx, tagExpr);
|
||||
}
|
||||
}
|
||||
|
||||
var props = node.attributes;
|
||||
if (props.length) {
|
||||
props = t.objectExpression(props);
|
||||
} else {
|
||||
props = t.literal(null);
|
||||
}
|
||||
|
||||
return t.callExpression(tagExpr, [props]);
|
||||
}
|
||||
};
|
||||
|
||||
exports.XJSElement = {
|
||||
exit: function (node) {
|
||||
var callExpr = node.openingElement;
|
||||
var children = node.children;
|
||||
|
||||
_.each(children, function (child) {
|
||||
callExpr.arguments.push(child);
|
||||
});
|
||||
|
||||
return t.inherits(callExpr, node);
|
||||
}
|
||||
};
|
||||
@@ -133,7 +133,7 @@ var checkFor = function (forParent, block) {
|
||||
} else if (t.isReturnStatement(node)) {
|
||||
has.hasReturn = true;
|
||||
replace = t.returnStatement(t.objectExpression([
|
||||
t.property("init", t.identifier("v"), node.argument)
|
||||
t.property("init", t.identifier("v"), node.argument || t.identifier("undefined"))
|
||||
]));
|
||||
}
|
||||
|
||||
@@ -286,16 +286,13 @@ var run = function (forParent, block, parent, file, scope) {
|
||||
|
||||
var retCheck;
|
||||
|
||||
var cases = [];
|
||||
|
||||
if (has.hasReturn) {
|
||||
// typeof ret === "object"
|
||||
retCheck = util.template("let-scoping-return", {
|
||||
RETURN: ret,
|
||||
});
|
||||
|
||||
// there's no `break` or `continue` so we can just push in the `if`
|
||||
if (!has.hasBreak && !has.hasContinue) {
|
||||
body.push(retCheck);
|
||||
}
|
||||
}
|
||||
|
||||
if (has.hasBreak || has.hasContinue) {
|
||||
@@ -303,8 +300,6 @@ var run = function (forParent, block, parent, file, scope) {
|
||||
// need to be able to access it
|
||||
var label = forParent.label = forParent.label || t.identifier(file.generateUid("loop", scope));
|
||||
|
||||
var cases = [];
|
||||
|
||||
if (has.hasBreak) {
|
||||
cases.push(t.switchCase(t.literal("break"), [t.breakStatement(label)]));
|
||||
}
|
||||
@@ -317,7 +312,17 @@ var run = function (forParent, block, parent, file, scope) {
|
||||
cases.push(t.switchCase(null, [retCheck]));
|
||||
}
|
||||
|
||||
body.push(t.switchStatement(ret, cases));
|
||||
if (cases.length === 1) {
|
||||
var single = cases[0];
|
||||
body.push(t.ifStatement(
|
||||
t.binaryExpression("===", ret, single.test),
|
||||
single.consequent[0]
|
||||
));
|
||||
} else {
|
||||
body.push(t.switchStatement(ret, cases));
|
||||
}
|
||||
} else {
|
||||
if (has.hasReturn) body.push(retCheck);
|
||||
}
|
||||
} else {
|
||||
body.push(t.expressionStatement(call));
|
||||
|
||||
99
lib/6to5/transformation/transformers/react.js
vendored
99
lib/6to5/transformation/transformers/react.js
vendored
@@ -1,5 +1,100 @@
|
||||
var t = require("../../types");
|
||||
var _ = require("lodash");
|
||||
// Based upon the excellent jsx-transpiler by Ingvar Stepanyan (RReverser)
|
||||
// https://github.com/RReverser/jsx-transpiler
|
||||
|
||||
// jsx
|
||||
|
||||
var esutils = require("esutils");
|
||||
var t = require("../../types");
|
||||
var _ = require("lodash");
|
||||
|
||||
exports.XJSIdentifier = function (node) {
|
||||
if (esutils.keyword.isIdentifierName(node.name)) {
|
||||
node.type = "Identifier";
|
||||
} else {
|
||||
return t.literal(node.name);
|
||||
}
|
||||
};
|
||||
|
||||
exports.XJSNamespacedName = function (node, parent, file) {
|
||||
throw file.errorWithNode(node, "Namespace tags are not supported. ReactJSX is not XML.");
|
||||
};
|
||||
|
||||
exports.XJSMemberExpression = {
|
||||
exit: function (node) {
|
||||
node.computed = t.isLiteral(node.property);
|
||||
node.type = "MemberExpression";
|
||||
}
|
||||
};
|
||||
|
||||
exports.XJSExpressionContainer = function (node) {
|
||||
return node.expression;
|
||||
};
|
||||
|
||||
exports.XJSAttribute = {
|
||||
exit: function (node) {
|
||||
var value = node.value || t.literal(true);
|
||||
return t.property("init", node.name, value);
|
||||
}
|
||||
};
|
||||
|
||||
exports.XJSOpeningElement = {
|
||||
exit: function (node) {
|
||||
var tagExpr = node.name;
|
||||
var args = [];
|
||||
|
||||
var tagName;
|
||||
if (t.isIdentifier(tagExpr)) {
|
||||
tagName = tagExpr.name;
|
||||
} else if (t.isLiteral(tagExpr)) {
|
||||
tagName = tagExpr.value;
|
||||
}
|
||||
|
||||
if (tagName && (/[a-z]/.exec(tagName[0]) || _.contains(tagName, "-"))) {
|
||||
args.push(t.literal(tagName));
|
||||
} else {
|
||||
args.push(tagExpr);
|
||||
}
|
||||
|
||||
var props = node.attributes;
|
||||
if (props.length) {
|
||||
var first = props[0];
|
||||
if (t.isXJSSpreadAttribute(first)) {
|
||||
props.shift();
|
||||
props = t.callExpression(
|
||||
t.memberExpression(t.identifier("React"), t.identifier("__spread")),
|
||||
[t.objectExpression([]), first.argument, t.objectExpression(props)]
|
||||
);
|
||||
} else {
|
||||
props = t.objectExpression(props);
|
||||
}
|
||||
} else {
|
||||
props = t.literal(null);
|
||||
}
|
||||
|
||||
args.push(props);
|
||||
|
||||
tagExpr = t.memberExpression(t.identifier("React"), t.identifier("createElement"));
|
||||
return t.callExpression(tagExpr, args);
|
||||
}
|
||||
};
|
||||
|
||||
exports.XJSElement = {
|
||||
exit: function (node) {
|
||||
var callExpr = node.openingElement;
|
||||
|
||||
var childrenToRender = node.children.filter(function(child) {
|
||||
return !(t.isLiteral(child) && _.isString(child.value) && child.value.match(/^[ \t]*[\r\n][ \t\r\n]*$/));
|
||||
});
|
||||
|
||||
_.each(childrenToRender, function (child) {
|
||||
callExpr.arguments.push(child);
|
||||
});
|
||||
|
||||
return t.inherits(callExpr, node);
|
||||
}
|
||||
};
|
||||
|
||||
// display names
|
||||
|
||||
var addDisplayName = function (id, call) {
|
||||
if (!call || !t.isCallExpression(call)) return;
|
||||
|
||||
@@ -40,8 +40,6 @@ function traverse(parent, callbacks, opts) {
|
||||
// type is blacklisted
|
||||
if (_.contains(blacklistTypes, node.type)) return;
|
||||
|
||||
var result;
|
||||
|
||||
// replace node
|
||||
var maybeReplace = function (result) {
|
||||
if (result === false) return;
|
||||
@@ -54,12 +52,11 @@ function traverse(parent, callbacks, opts) {
|
||||
|
||||
// enter
|
||||
if (callbacks.enter) {
|
||||
result = callbacks.enter(node, parent, opts2.scope);
|
||||
var result = callbacks.enter(node, parent, opts2.scope);
|
||||
maybeReplace(result);
|
||||
|
||||
// stop iteration
|
||||
if (result === false) return;
|
||||
|
||||
maybeReplace(result);
|
||||
}
|
||||
|
||||
// traverse node
|
||||
@@ -114,25 +111,18 @@ traverse.hasType = function (tree, type, blacklistTypes) {
|
||||
|
||||
var has = false;
|
||||
|
||||
if (_.isArray(tree)) {
|
||||
// array of nodes, find the first
|
||||
return tree.some(function (node) {
|
||||
return traverse.hasType(node, type, blacklistTypes);
|
||||
});
|
||||
} else {
|
||||
// the node we're searching in is blacklisted
|
||||
if (_.contains(blacklistTypes, tree.type)) return false;
|
||||
// the node we're searching in is blacklisted
|
||||
if (_.contains(blacklistTypes, tree.type)) return false;
|
||||
|
||||
// the type we're looking for is the same as the passed node
|
||||
if (tree.type === type) return true;
|
||||
// the type we're looking for is the same as the passed node
|
||||
if (tree.type === type) return true;
|
||||
|
||||
traverse(tree, function (node) {
|
||||
if (node.type === type) {
|
||||
has = true;
|
||||
return false;
|
||||
}
|
||||
}, { blacklist: blacklistTypes });
|
||||
}
|
||||
traverse(tree, function (node) {
|
||||
if (node.type === type) {
|
||||
has = true;
|
||||
return false;
|
||||
}
|
||||
}, { blacklist: blacklistTypes });
|
||||
|
||||
return has;
|
||||
};
|
||||
|
||||
@@ -205,10 +205,12 @@ t.getIds.arrays = {
|
||||
};
|
||||
|
||||
t.inherits = function (child, parent) {
|
||||
child.loc = parent.loc;
|
||||
child.end = parent.end;
|
||||
child.range = parent.range;
|
||||
child.start = parent.start;
|
||||
child.loc = parent.loc;
|
||||
child.end = parent.end;
|
||||
child.range = parent.range;
|
||||
child.start = parent.start;
|
||||
child.leadingComments = parent.leadingComments;
|
||||
child.trailingComments = parent.trailingComments;
|
||||
return child;
|
||||
};
|
||||
|
||||
|
||||
@@ -71,6 +71,6 @@
|
||||
"XJSMemberExpression": ["object", "property"],
|
||||
"XJSNamespacedName": ["namespace", "name"],
|
||||
"XJSOpeningElement": ["name", "attributes"],
|
||||
"XJSSpreadAttribute": [],
|
||||
"XJSSpreadAttribute": ["argument"],
|
||||
"YieldExpression": ["argument"]
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "6to5",
|
||||
"description": "Turn ES6 code into readable vanilla ES5 with source maps",
|
||||
"version": "1.11.13",
|
||||
"version": "1.12.0",
|
||||
"author": "Sebastian McKenzie <sebmck@gmail.com>",
|
||||
"homepage": "https://github.com/6to5/6to5",
|
||||
"repository": {
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
/** @jsx CUSTOM_DOM */
|
||||
|
||||
<a></a>
|
||||
@@ -1,5 +0,0 @@
|
||||
/** @jsx CUSTOM_DOM */
|
||||
|
||||
"use strict";
|
||||
|
||||
CUSTOM_DOM.a(null);
|
||||
@@ -1 +0,0 @@
|
||||
<X>{}</X>
|
||||
@@ -1,3 +0,0 @@
|
||||
"use strict";
|
||||
|
||||
X(null, null);
|
||||
@@ -1,2 +0,0 @@
|
||||
<X data-prop={x ? <Y prop={2} /> : <Z>
|
||||
</Z>}></X>
|
||||
@@ -1,7 +0,0 @@
|
||||
"use strict";
|
||||
|
||||
X({
|
||||
"data-prop": x ? Y({
|
||||
prop: 2
|
||||
}) : Z(null, "\n")
|
||||
});
|
||||
@@ -1,5 +0,0 @@
|
||||
(<X>{a}</X>);
|
||||
|
||||
(<X>{a} {b}</X>);
|
||||
|
||||
(<X prop={a} yes></X>);
|
||||
@@ -1,10 +0,0 @@
|
||||
"use strict";
|
||||
|
||||
(X(null, a));
|
||||
|
||||
(X(null, a, " ", b));
|
||||
|
||||
(X({
|
||||
prop: a,
|
||||
yes: true
|
||||
}));
|
||||
@@ -1 +0,0 @@
|
||||
<a></a>
|
||||
@@ -1,3 +0,0 @@
|
||||
"use strict";
|
||||
|
||||
React.DOM.a(null);
|
||||
@@ -1 +0,0 @@
|
||||
<Test.X></Test.X>
|
||||
@@ -1,3 +0,0 @@
|
||||
"use strict";
|
||||
|
||||
Test.X(null);
|
||||
@@ -1 +0,0 @@
|
||||
<Test:X></Test:X>
|
||||
@@ -1,3 +0,0 @@
|
||||
(<X />);
|
||||
|
||||
(<X prop="1" />);
|
||||
@@ -1,7 +0,0 @@
|
||||
"use strict";
|
||||
|
||||
(X(null));
|
||||
|
||||
(X({
|
||||
prop: "1"
|
||||
}));
|
||||
@@ -1 +0,0 @@
|
||||
<X></X>
|
||||
@@ -1,3 +0,0 @@
|
||||
"use strict";
|
||||
|
||||
X(null);
|
||||
@@ -1,3 +0,0 @@
|
||||
(<X prop="2"><Y /></X>);
|
||||
|
||||
(<X prop="2"><Y /><Z /></X>);
|
||||
@@ -1,9 +0,0 @@
|
||||
"use strict";
|
||||
|
||||
(X({
|
||||
prop: "2"
|
||||
}, Y(null)));
|
||||
|
||||
(X({
|
||||
prop: "2"
|
||||
}, Y(null), Z(null)));
|
||||
@@ -1,13 +0,0 @@
|
||||
(<X> </X>);
|
||||
|
||||
(<X>
|
||||
</X>);
|
||||
|
||||
(<X>
|
||||
string
|
||||
</X>);
|
||||
|
||||
(<X>
|
||||
string
|
||||
string
|
||||
</X>);
|
||||
@@ -1,9 +0,0 @@
|
||||
"use strict";
|
||||
|
||||
(X(null, " "));
|
||||
|
||||
(X(null, "\n"));
|
||||
|
||||
(X(null, "\n string\n"));
|
||||
|
||||
(X(null, "\n string\n string\n "));
|
||||
10
test/fixtures/transformation/let-scoping/for-break-continue-return/actual.js
vendored
Normal file
10
test/fixtures/transformation/let-scoping/for-break-continue-return/actual.js
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
for (let i in nums) {
|
||||
fns.push(function () { return i; });
|
||||
if (i === 1) {
|
||||
continue;
|
||||
} else if (i === 2) {
|
||||
break;
|
||||
} else if (i === 3) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
24
test/fixtures/transformation/let-scoping/for-break-continue-return/expected.js
vendored
Normal file
24
test/fixtures/transformation/let-scoping/for-break-continue-return/expected.js
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
"use strict";
|
||||
|
||||
_loop: for (var i in nums) {
|
||||
var _ret = (function (i) {
|
||||
fns.push(function () {
|
||||
return i;
|
||||
});
|
||||
if (i === 1) {
|
||||
return "continue";
|
||||
} else if (i === 2) {
|
||||
return "break";
|
||||
} else if (i === 3) {
|
||||
return {
|
||||
v: i
|
||||
};
|
||||
}
|
||||
})(i);
|
||||
|
||||
switch (_ret) {
|
||||
case "break": break _loop;
|
||||
case "continue": continue _loop;
|
||||
default: if (typeof _ret === "object") return _ret.v;
|
||||
}
|
||||
}
|
||||
4
test/fixtures/transformation/let-scoping/for-break/actual.js
vendored
Normal file
4
test/fixtures/transformation/let-scoping/for-break/actual.js
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
for (let i in nums) {
|
||||
fns.push(function () { return i; });
|
||||
break;
|
||||
}
|
||||
12
test/fixtures/transformation/let-scoping/for-break/expected.js
vendored
Normal file
12
test/fixtures/transformation/let-scoping/for-break/expected.js
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
"use strict";
|
||||
|
||||
_loop: for (var i in nums) {
|
||||
var _ret = (function (i) {
|
||||
fns.push(function () {
|
||||
return i;
|
||||
});
|
||||
return "break";
|
||||
})(i);
|
||||
|
||||
if (_ret === "break") break _loop;
|
||||
}
|
||||
4
test/fixtures/transformation/let-scoping/for-continue/actual.js
vendored
Normal file
4
test/fixtures/transformation/let-scoping/for-continue/actual.js
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
for (let i in nums) {
|
||||
fns.push(function () { return i; });
|
||||
continue;
|
||||
}
|
||||
12
test/fixtures/transformation/let-scoping/for-continue/expected.js
vendored
Normal file
12
test/fixtures/transformation/let-scoping/for-continue/expected.js
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
"use strict";
|
||||
|
||||
_loop: for (var i in nums) {
|
||||
var _ret = (function (i) {
|
||||
fns.push(function () {
|
||||
return i;
|
||||
});
|
||||
return "continue";
|
||||
})(i);
|
||||
|
||||
if (_ret === "continue") continue _loop;
|
||||
}
|
||||
4
test/fixtures/transformation/let-scoping/for-return-undefined/actual.js
vendored
Normal file
4
test/fixtures/transformation/let-scoping/for-return-undefined/actual.js
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
for (let i in nums) {
|
||||
fns.push(function () { return i; });
|
||||
return;
|
||||
}
|
||||
14
test/fixtures/transformation/let-scoping/for-return-undefined/expected.js
vendored
Normal file
14
test/fixtures/transformation/let-scoping/for-return-undefined/expected.js
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
"use strict";
|
||||
|
||||
for (var i in nums) {
|
||||
var _ret = (function (i) {
|
||||
fns.push(function () {
|
||||
return i;
|
||||
});
|
||||
return {
|
||||
v: undefined
|
||||
};
|
||||
})(i);
|
||||
|
||||
if (typeof _ret === "object") return _ret.v;
|
||||
}
|
||||
4
test/fixtures/transformation/let-scoping/for-return/actual.js
vendored
Normal file
4
test/fixtures/transformation/let-scoping/for-return/actual.js
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
for (let i in nums) {
|
||||
fns.push(function () { return i; });
|
||||
return i;
|
||||
}
|
||||
14
test/fixtures/transformation/let-scoping/for-return/expected.js
vendored
Normal file
14
test/fixtures/transformation/let-scoping/for-return/expected.js
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
"use strict";
|
||||
|
||||
for (var i in nums) {
|
||||
var _ret = (function (i) {
|
||||
fns.push(function () {
|
||||
return i;
|
||||
});
|
||||
return {
|
||||
v: i
|
||||
};
|
||||
})(i);
|
||||
|
||||
if (typeof _ret === "object") return _ret.v;
|
||||
}
|
||||
3
test/fixtures/transformation/let-scoping/function/actual.js
vendored
Normal file
3
test/fixtures/transformation/let-scoping/function/actual.js
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
function test() {
|
||||
let foo = "bar";
|
||||
}
|
||||
5
test/fixtures/transformation/let-scoping/function/expected.js
vendored
Normal file
5
test/fixtures/transformation/let-scoping/function/expected.js
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
"use strict";
|
||||
|
||||
function test() {
|
||||
var foo = "bar";
|
||||
}
|
||||
1
test/fixtures/transformation/let-scoping/program/actual.js
vendored
Normal file
1
test/fixtures/transformation/let-scoping/program/actual.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
let test = "foo";
|
||||
3
test/fixtures/transformation/let-scoping/program/expected.js
vendored
Normal file
3
test/fixtures/transformation/let-scoping/program/expected.js
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
"use strict";
|
||||
|
||||
var test = "foo";
|
||||
3
test/fixtures/transformation/misc/custom-runtime/actual.js
vendored
Normal file
3
test/fixtures/transformation/misc/custom-runtime/actual.js
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
function foo(...test) {
|
||||
|
||||
}
|
||||
5
test/fixtures/transformation/misc/custom-runtime/expected.js
vendored
Normal file
5
test/fixtures/transformation/misc/custom-runtime/expected.js
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
"use strict";
|
||||
|
||||
function foo() {
|
||||
var test = customNamespace.slice.call(arguments);
|
||||
}
|
||||
3
test/fixtures/transformation/misc/custom-runtime/options.json
vendored
Normal file
3
test/fixtures/transformation/misc/custom-runtime/options.json
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"runtime": "customNamespace"
|
||||
}
|
||||
3
test/fixtures/transformation/misc/property-literals/actual.js
vendored
Normal file
3
test/fixtures/transformation/misc/property-literals/actual.js
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
var obj = {
|
||||
"foobar": "lol"
|
||||
};
|
||||
5
test/fixtures/transformation/misc/property-literals/expected.js
vendored
Normal file
5
test/fixtures/transformation/misc/property-literals/expected.js
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
"use strict";
|
||||
|
||||
var obj = {
|
||||
foobar: "lol"
|
||||
};
|
||||
3
test/fixtures/transformation/misc/runtime/actual.js
vendored
Normal file
3
test/fixtures/transformation/misc/runtime/actual.js
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
function foo(...test) {
|
||||
|
||||
}
|
||||
5
test/fixtures/transformation/misc/runtime/expected.js
vendored
Normal file
5
test/fixtures/transformation/misc/runtime/expected.js
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
"use strict";
|
||||
|
||||
function foo() {
|
||||
var test = to5Runtime.slice.call(arguments);
|
||||
}
|
||||
3
test/fixtures/transformation/misc/runtime/options.json
vendored
Normal file
3
test/fixtures/transformation/misc/runtime/options.json
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"runtime": true
|
||||
}
|
||||
3
test/fixtures/transformation/misc/shebang/actual.js
vendored
Normal file
3
test/fixtures/transformation/misc/shebang/actual.js
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
foobar();
|
||||
4
test/fixtures/transformation/misc/shebang/expected.js
vendored
Normal file
4
test/fixtures/transformation/misc/shebang/expected.js
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
#!/usr/bin/env node
|
||||
"use strict";
|
||||
|
||||
foobar();
|
||||
@@ -0,0 +1 @@
|
||||
<div> </div>;
|
||||
@@ -0,0 +1 @@
|
||||
React.createElement("div", null, "\u00A0 ");
|
||||
@@ -0,0 +1 @@
|
||||
<div> </div>;
|
||||
@@ -0,0 +1 @@
|
||||
React.createElement("div", null, "\u00A0");
|
||||
@@ -0,0 +1,13 @@
|
||||
var x = (
|
||||
<div>
|
||||
{/* A comment at the beginning */}
|
||||
{/* A second comment at the beginning */}
|
||||
<span>
|
||||
{/* A nested comment */}
|
||||
</span>
|
||||
{/* A sandwiched comment */}
|
||||
<br />
|
||||
{/* A comment at the end */}
|
||||
{/* A second comment at the end */}
|
||||
</div>
|
||||
);
|
||||
@@ -0,0 +1,11 @@
|
||||
var x = (React.createElement("div", null,
|
||||
/* A comment at the beginning */
|
||||
/* A second comment at the beginning */
|
||||
React.createElement("span", null
|
||||
/* A nested comment */
|
||||
),
|
||||
/* A sandwiched comment */
|
||||
React.createElement("br", null)
|
||||
/* A comment at the end */
|
||||
/* A second comment at the end */
|
||||
));
|
||||
10
test/fixtures/transformation/react/.should-properly-handle-comments-between-props/actual.js
vendored
Normal file
10
test/fixtures/transformation/react/.should-properly-handle-comments-between-props/actual.js
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
var x = (
|
||||
<div
|
||||
/* a multi-line
|
||||
comment */
|
||||
attr1="foo">
|
||||
<span // a double-slash comment
|
||||
attr2="bar"
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
@@ -0,0 +1,8 @@
|
||||
var x = (React.createElement("div", {
|
||||
/* a multi-line
|
||||
comment */
|
||||
attr1: "foo"},
|
||||
React.createElement("span", {// a double-slash comment
|
||||
attr2: "bar"}
|
||||
)
|
||||
));
|
||||
@@ -0,0 +1,3 @@
|
||||
<Component
|
||||
{...this.props}
|
||||
sound="moo" />
|
||||
@@ -0,0 +1,3 @@
|
||||
React.createElement(Component, React.__spread({}, this.props, {
|
||||
sound: "moo"
|
||||
}));
|
||||
@@ -1,5 +1,3 @@
|
||||
"use strict";
|
||||
|
||||
var Component;
|
||||
Component = React.createClass({
|
||||
displayName: "Component",
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
"use strict";
|
||||
|
||||
var Whateva = React.createClass({
|
||||
displayName: "Whatever",
|
||||
render: function () {
|
||||
return null;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
"use strict";
|
||||
|
||||
exports = {
|
||||
Component: React.createClass({
|
||||
displayName: "Component",
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
"use strict";
|
||||
|
||||
exports.Component = React.createClass({
|
||||
displayName: "Component",
|
||||
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
"use strict";
|
||||
|
||||
var Component = React.createClass({
|
||||
displayName: "Component",
|
||||
|
||||
|
||||
3
test/fixtures/transformation/react/options.json
vendored
Normal file
3
test/fixtures/transformation/react/options.json
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"blacklist": ["useStrict"]
|
||||
}
|
||||
1
test/fixtures/transformation/react/should-allow-constructor-as-prop/actual.js
vendored
Normal file
1
test/fixtures/transformation/react/should-allow-constructor-as-prop/actual.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
<Component constructor="foo" />;
|
||||
3
test/fixtures/transformation/react/should-allow-constructor-as-prop/expected.js
vendored
Normal file
3
test/fixtures/transformation/react/should-allow-constructor-as-prop/expected.js
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
React.createElement(Component, {
|
||||
constructor: "foo"
|
||||
});
|
||||
1
test/fixtures/transformation/react/should-allow-deeper-js-namespacing/actual.js
vendored
Normal file
1
test/fixtures/transformation/react/should-allow-deeper-js-namespacing/actual.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
<Namespace.DeepNamespace.Component />;
|
||||
1
test/fixtures/transformation/react/should-allow-deeper-js-namespacing/expected.js
vendored
Normal file
1
test/fixtures/transformation/react/should-allow-deeper-js-namespacing/expected.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
React.createElement(Namespace.DeepNamespace.Component, null);
|
||||
1
test/fixtures/transformation/react/should-allow-js-namespacing/actual.js
vendored
Normal file
1
test/fixtures/transformation/react/should-allow-js-namespacing/actual.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
<Namespace.Component />;
|
||||
1
test/fixtures/transformation/react/should-allow-js-namespacing/blacklist.js
vendored
Normal file
1
test/fixtures/transformation/react/should-allow-js-namespacing/blacklist.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
React.createElement(Namespace.Component, null);
|
||||
1
test/fixtures/transformation/react/should-allow-js-namespacing/expected.js
vendored
Normal file
1
test/fixtures/transformation/react/should-allow-js-namespacing/expected.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
React.createElement(Namespace.Component, null);
|
||||
15
test/fixtures/transformation/react/should-avoid-wrapping-in-extra-parens-if-not-needed/actual.js
vendored
Normal file
15
test/fixtures/transformation/react/should-avoid-wrapping-in-extra-parens-if-not-needed/actual.js
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
var x = <div>
|
||||
<Component />
|
||||
</div>;
|
||||
|
||||
var x = <div>
|
||||
{this.props.children}
|
||||
</div>;
|
||||
|
||||
var x = <Composite>
|
||||
{this.props.children}
|
||||
</Composite>;
|
||||
|
||||
var x = <Composite>
|
||||
<Composite2 />
|
||||
</Composite>;
|
||||
@@ -0,0 +1,7 @@
|
||||
var x = React.createElement("div", null, React.createElement(Component, null));
|
||||
|
||||
var x = React.createElement("div", null, this.props.children);
|
||||
|
||||
var x = React.createElement(Composite, null, this.props.children);
|
||||
|
||||
var x = React.createElement(Composite, null, React.createElement(Composite2, null));
|
||||
1
test/fixtures/transformation/react/should-convert-simple-tags/actual.js
vendored
Normal file
1
test/fixtures/transformation/react/should-convert-simple-tags/actual.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
var x = <div></div>;
|
||||
1
test/fixtures/transformation/react/should-convert-simple-tags/expected.js
vendored
Normal file
1
test/fixtures/transformation/react/should-convert-simple-tags/expected.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
var x = React.createElement("div", null);
|
||||
1
test/fixtures/transformation/react/should-convert-simple-text/actual.js
vendored
Normal file
1
test/fixtures/transformation/react/should-convert-simple-text/actual.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
var x = <div>text</div>;
|
||||
1
test/fixtures/transformation/react/should-convert-simple-text/expected.js
vendored
Normal file
1
test/fixtures/transformation/react/should-convert-simple-text/expected.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
var x = React.createElement("div", null, "text");
|
||||
1
test/fixtures/transformation/react/should-disallow-xml-namespacing/actual.js
vendored
Normal file
1
test/fixtures/transformation/react/should-disallow-xml-namespacing/actual.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
<Namespace:Component />;
|
||||
1
test/fixtures/transformation/react/should-handle-has-own-property-correctly/actual.js
vendored
Normal file
1
test/fixtures/transformation/react/should-handle-has-own-property-correctly/actual.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
<hasOwnProperty>testing</hasOwnProperty>;
|
||||
1
test/fixtures/transformation/react/should-handle-has-own-property-correctly/expected.js
vendored
Normal file
1
test/fixtures/transformation/react/should-handle-has-own-property-correctly/expected.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
React.createElement("hasOwnProperty", null, "testing");
|
||||
5
test/fixtures/transformation/react/should-have-correct-comma-in-nested-children/actual.js
vendored
Normal file
5
test/fixtures/transformation/react/should-have-correct-comma-in-nested-children/actual.js
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
var x = <div>
|
||||
<div><br /></div>
|
||||
<Component>{foo}<br />{bar}</Component>
|
||||
<br />
|
||||
</div>;
|
||||
1
test/fixtures/transformation/react/should-have-correct-comma-in-nested-children/expected.js
vendored
Normal file
1
test/fixtures/transformation/react/should-have-correct-comma-in-nested-children/expected.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
var x = React.createElement("div", null, React.createElement("div", null, React.createElement("br", null)), React.createElement(Component, null, foo, React.createElement("br", null), bar), React.createElement("br", null));
|
||||
@@ -0,0 +1,16 @@
|
||||
var x =
|
||||
<div
|
||||
attr1={
|
||||
"foo" + "bar"
|
||||
}
|
||||
attr2={
|
||||
"foo" + "bar" +
|
||||
|
||||
"baz" + "bug"
|
||||
}
|
||||
attr3={
|
||||
"foo" + "bar" +
|
||||
"baz" + "bug"
|
||||
}
|
||||
attr4="baz">
|
||||
</div>
|
||||
@@ -0,0 +1,6 @@
|
||||
var x = React.createElement("div", {
|
||||
attr1: "foo" + "bar",
|
||||
attr2: "foo" + "bar" + "baz" + "bug",
|
||||
attr3: "foo" + "bar" + "baz" + "bug",
|
||||
attr4: "baz"
|
||||
});
|
||||
1
test/fixtures/transformation/react/should-transform-known-hyphenated-tags/actual.js
vendored
Normal file
1
test/fixtures/transformation/react/should-transform-known-hyphenated-tags/actual.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
<font-face />;
|
||||
1
test/fixtures/transformation/react/should-transform-known-hyphenated-tags/expected.js
vendored
Normal file
1
test/fixtures/transformation/react/should-transform-known-hyphenated-tags/expected.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
React.createElement("font-face", null);
|
||||
@@ -0,0 +1,2 @@
|
||||
<Component { ... x } y
|
||||
={2 } z />
|
||||
@@ -0,0 +1,4 @@
|
||||
React.createElement(Component, React.__spread({}, x, {
|
||||
y: 2,
|
||||
z: true
|
||||
}));
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user