Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8b46cce466 | ||
|
|
defa9108bd | ||
|
|
6b1d9b49b7 | ||
|
|
4e333cf357 |
@@ -1,3 +1,7 @@
|
||||
# 1.12.26
|
||||
|
||||
* Support computed property destructuring.
|
||||
|
||||
# 1.12.25
|
||||
|
||||
* Update `acorn-6to5`, `ast-types`, `es6-shim`, `chokidar`, `estraverse` and `private`.
|
||||
|
||||
@@ -78,7 +78,7 @@ AMDFormatter.prototype._push = function (node) {
|
||||
if (ids[id]) {
|
||||
return ids[id];
|
||||
} else {
|
||||
return this.ids[id] = t.identifier(this.file.generateUid(id));
|
||||
return this.ids[id] = this.file.generateUidIdentifier(id);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ var singleArrayExpression = function (node) {
|
||||
};
|
||||
|
||||
var multiple = function (node, file) {
|
||||
var uid = file.generateUid("arr");
|
||||
var uid = file.generateUidIdentifier("arr");
|
||||
|
||||
var container = util.template("array-comprehension-container", {
|
||||
KEY: uid
|
||||
|
||||
@@ -27,7 +27,7 @@ var push = function (opts, nodes, elem, parentId) {
|
||||
var pushObjectPattern = function (opts, nodes, pattern, parentId) {
|
||||
_.each(pattern.properties, function (prop) {
|
||||
var pattern2 = prop.value;
|
||||
var patternId2 = t.memberExpression(parentId, prop.key);
|
||||
var patternId2 = t.memberExpression(parentId, prop.key, prop.computed);
|
||||
|
||||
if (t.isPattern(pattern2)) {
|
||||
push(opts, nodes, pattern2, patternId2);
|
||||
@@ -38,7 +38,7 @@ var pushObjectPattern = function (opts, nodes, pattern, parentId) {
|
||||
};
|
||||
|
||||
var pushArrayPattern = function (opts, nodes, pattern, parentId) {
|
||||
var _parentId = t.identifier(opts.file.generateUid("ref", opts.scope));
|
||||
var _parentId = opts.file.generateUidIdentifier("ref", opts.scope);
|
||||
nodes.push(t.variableDeclaration("var", [
|
||||
t.variableDeclarator(_parentId, util.template("array-from", {
|
||||
VALUE: parentId
|
||||
|
||||
@@ -19,7 +19,7 @@ exports.ForOfStatement = function (node, parent, file, scope) {
|
||||
}
|
||||
|
||||
var node2 = util.template("for-of", {
|
||||
ITERATOR_KEY: file.generateUid("iterator", scope),
|
||||
ITERATOR_KEY: file.generateUidIdentifier("iterator", scope),
|
||||
STEP_KEY: stepKey,
|
||||
OBJECT: node.right
|
||||
});
|
||||
|
||||
@@ -129,7 +129,7 @@ LetScoping.prototype.run = function () {
|
||||
|
||||
// build a call and a unique id that we can assign the return value to
|
||||
var call = t.callExpression(fn, params);
|
||||
var ret = t.identifier(this.file.generateUid("ret", this.scope));
|
||||
var ret = this.file.generateUidIdentifier("ret", this.scope);
|
||||
|
||||
var hasYield = traverse.hasType(fn.body, "YieldExpression", t.FUNCTION_TYPES);
|
||||
if (hasYield) {
|
||||
@@ -445,7 +445,7 @@ LetScoping.prototype.buildHas = function (ret, call) {
|
||||
if (has.hasBreak || has.hasContinue) {
|
||||
// ensure that the parent has a label as we're building a switch and we
|
||||
// need to be able to access it
|
||||
var label = forParent.label = forParent.label || t.identifier(this.file.generateUid("loop", this.scope));
|
||||
var label = forParent.label = forParent.label || this.file.generateUidIdentifier("loop", this.scope);
|
||||
|
||||
if (has.hasBreak) {
|
||||
cases.push(t.switchCase(t.literal("break"), [t.breakStatement(label)]));
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "6to5",
|
||||
"description": "Turn ES6 code into readable vanilla ES5 with source maps",
|
||||
"version": "1.12.25",
|
||||
"version": "1.12.26",
|
||||
"author": "Sebastian McKenzie <sebmck@gmail.com>",
|
||||
"homepage": "https://github.com/6to5/6to5",
|
||||
"repository": {
|
||||
|
||||
1
test/fixtures/transformation/destructuring/assignment-expression-statement-only/actual.js
vendored
Normal file
1
test/fixtures/transformation/destructuring/assignment-expression-statement-only/actual.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
console.log([x] = [1]);
|
||||
3
test/fixtures/transformation/destructuring/assignment-expression-statement-only/options.json
vendored
Normal file
3
test/fixtures/transformation/destructuring/assignment-expression-statement-only/options.json
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"throws": "AssignmentExpression destructuring outside of a ExpressionStatement is forbidden due to current 6to5 limitations"
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
var Component = React.createClass({
|
||||
render: function () {
|
||||
return null;
|
||||
return null;
|
||||
}
|
||||
});
|
||||
|
||||
30
test/util.js
30
test/util.js
@@ -3,8 +3,6 @@ var util = require("../lib/6to5/util");
|
||||
var t = require("../lib/6to5/types");
|
||||
|
||||
suite("util", function () {
|
||||
test("duplicate mutator map");
|
||||
|
||||
test("invalid template", function () {
|
||||
assert.throws(function () {
|
||||
util.template("invalid template");
|
||||
@@ -45,6 +43,34 @@ suite("util", function () {
|
||||
assert.deepEqual(util.list("foo,bar"), ["foo", "bar"]);
|
||||
});
|
||||
|
||||
test("arrayify", function () {
|
||||
assert.deepEqual(util.arrayify(undefined), []);
|
||||
assert.deepEqual(util.arrayify(false), []);
|
||||
assert.deepEqual(util.arrayify(null), []);
|
||||
assert.deepEqual(util.arrayify(""), []);
|
||||
assert.deepEqual(util.arrayify("foo"), ["foo"]);
|
||||
assert.deepEqual(util.arrayify("foo,bar"), ["foo", "bar"]);
|
||||
assert.deepEqual(util.arrayify(["foo", "bar"]), ["foo", "bar"]);
|
||||
|
||||
assert.throws(function () {
|
||||
util.arrayify({});
|
||||
}, /illegal type for arrayify/);
|
||||
});
|
||||
|
||||
test("regexify", function () {
|
||||
assert.deepEqual(util.regexify(undefined), /(?:)/);
|
||||
assert.deepEqual(util.regexify(false), /(?:)/);
|
||||
assert.deepEqual(util.regexify(null), /(?:)/);
|
||||
assert.deepEqual(util.regexify(""), /(?:)/);
|
||||
assert.deepEqual(util.regexify(["foo", "bar"]), /foo|bar/);
|
||||
assert.deepEqual(util.regexify("foobar"), /foobar/);
|
||||
assert.deepEqual(util.regexify(/foobar/), /foobar/);
|
||||
|
||||
assert.throws(function () {
|
||||
util.regexify({});
|
||||
}, /illegal type for regexify/);
|
||||
});
|
||||
|
||||
test("getIds");
|
||||
|
||||
test("toStatement");
|
||||
|
||||
Reference in New Issue
Block a user