Compare commits

...

11 Commits

Author SHA1 Message Date
Sebastian McKenzie
f1a2401681 v1.14.2 2014-11-26 10:54:45 +11:00
Sebastian McKenzie
2d61672cdb add 1.14.2 changelog 2014-11-26 10:53:52 +11:00
Sebastian McKenzie
1b00ba21a1 fix commonInterop default export handling - fixes #223 2014-11-26 10:48:30 +11:00
Sebastian McKenzie
f8ea386f3c fix computed property literals - fixes #221 2014-11-26 10:47:23 +11:00
Sebastian McKenzie
2527fffbad merge memberExpressionKeywords and memberExpressionLiterals transformer 2014-11-26 10:46:32 +11:00
Sebastian McKenzie
86498ad990 fix memoisation operator example 2014-11-26 10:46:10 +11:00
Sebastian McKenzie
27c8804214 v1.14.1 2014-11-26 00:43:24 +11:00
Sebastian McKenzie
2b6f0ee780 add changelog for 1.14.1 2014-11-26 00:42:05 +11:00
Sebastian McKenzie
c7c9660c79 classes: make VariableDeclaration inherit comments from ClassDeclaration 2014-11-26 00:41:07 +11:00
Sebastian McKenzie
ff025e63ec add ParenthesizedExpression support to t.isDynamic 2014-11-26 00:40:42 +11:00
Sebastian McKenzie
9fb6681ad3 fix dot in playground docs 2014-11-26 00:08:34 +11:00
14 changed files with 45 additions and 35 deletions

View File

@@ -1,3 +1,12 @@
# 1.14.2
* Fix `commonInterop` default export handling.
* Fix keyworded property key identifiers being turned into computed property key literals.
# 1.14.1
* Inherit comments from `ClassDeclaration`.
# 1.14.0
* Add [playground](https://6to5.github.io/playground.html).

View File

@@ -44,10 +44,10 @@ equivalent to:
```javascript
var obj = {};
if (Object.prototype.hasOwnProperty.call(obj, "x")) obj.x = 2;
if (!Object.prototype.hasOwnProperty.call(obj, "x")) obj.x = 2;
```
### Method binding expression.
### Method binding expression
```javascript
var fn = obj:method;

View File

@@ -3,10 +3,16 @@ module.exports = CommonJSInteropFormatter;
var CommonJSFormatter = require("./common");
var util = require("../../util");
var t = require("../../types");
var _ = require("lodash");
function CommonJSInteropFormatter() {
this.has = false;
function CommonJSInteropFormatter(file) {
CommonJSFormatter.apply(this, arguments);
var has = false;
_.each(file.ast.program.body, function (node) {
if (t.isExportDeclaration(node) && !node.default) has = true;
});
this.has = has;
}
util.inherits(CommonJSInteropFormatter, CommonJSFormatter);
@@ -40,14 +46,11 @@ CommonJSInteropFormatter.prototype.export = function (node, nodes) {
// hoist to the top if this default is a function
nodes.push(this._hoistExport(declar, assign));
return;
} else {
this.has = true;
}
CommonJSFormatter.prototype.export.apply(this, arguments);
};
CommonJSInteropFormatter.prototype.exportSpecifier = function () {
this.has = true;
CommonJSFormatter.prototype.exportSpecifier.apply(this, arguments);
};

View File

@@ -68,7 +68,6 @@ _.each({
_propertyLiterals: require("./transformers/_property-literals"),
_memberExpressioLiterals: require("./transformers/_member-expression-literals"),
_memberExpressionKeywords: require("./transformers/_member-expression-keywords"),
_moduleFormatter: require("./transformers/_module-formatter")
}, function (transformer, key) {
transform.transformers[key] = new Transformer(key, transformer);

View File

@@ -1,10 +0,0 @@
var esutils = require("esutils");
var t = require("../../types");
exports.MemberExpression = function (node) {
var prop = node.property;
if (t.isIdentifier(prop) && esutils.keyword.isKeywordES6(prop.name, true)) {
node.property = t.literal(prop.name);
node.computed = true;
}
};

View File

@@ -1,4 +1,5 @@
var t = require("../../types");
var esutils = require("esutils");
var t = require("../../types");
exports.MemberExpression = function (node) {
var prop = node.property;
@@ -6,5 +7,8 @@ exports.MemberExpression = function (node) {
// computed literal that is a valid identifier
node.property = t.identifier(prop.value);
node.computed = false;
} else if (!node.computed && t.isIdentifier(prop) && esutils.keyword.isKeywordES6(prop.name, true)) {
node.property = t.literal(prop.name);
node.computed = true;
}
};

View File

@@ -7,9 +7,8 @@ exports.Property = function (node) {
// property key is a literal but a valid identifier
node.key = t.identifier(key.value);
node.computed = false;
} else if (t.isIdentifier(key) && esutils.keyword.isKeywordES6(key.name, true)) {
} else if (!node.computed && t.isIdentifier(key) && esutils.keyword.isKeywordES6(key.name, true)) {
// property key is a keyword
node.key = t.literal(key.name);
node.computed = true;
}
};

View File

@@ -4,9 +4,13 @@ var t = require("../../types");
var _ = require("lodash");
exports.ClassDeclaration = function (node, parent, file, scope) {
return t.variableDeclaration("let", [
t.variableDeclarator(node.id, new Class(node, file, scope).run())
var built = new Class(node, file, scope).run();
var declar = t.variableDeclaration("let", [
t.variableDeclarator(node.id, built)
]);
t.inheritsComments(declar, node);
return declar;
};
exports.ClassExpression = function (node, parent, file, scope) {

View File

@@ -114,7 +114,9 @@ t.shallowEqual = function (actual, expected) {
//
t.isDynamic = function (node) {
if (t.isIdentifier(node) || t.isLiteral(node) || t.isThisExpression(node)) {
if (t.isParenthesizedExpression(node)) {
return t.isDynamic(node.expression);
} else if (t.isIdentifier(node) || t.isLiteral(node) || t.isThisExpression(node)) {
return false;
} else if (t.isMemberExpression(node)) {
return t.isDynamic(node.object) || t.isDynamic(node.property);

View File

@@ -1,7 +1,7 @@
{
"name": "6to5",
"description": "Turn ES6 code into readable vanilla ES5 with source maps",
"version": "1.14.0",
"version": "1.14.2",
"author": "Sebastian McKenzie <sebmck@gmail.com>",
"homepage": "https://github.com/6to5/6to5",
"repository": {

View File

@@ -1,4 +0,0 @@
test.catch;
test.catch["foo"];
test["catch"];
test["catch"]["foo"];

View File

@@ -1,6 +0,0 @@
"use strict";
test["catch"];
test["catch"].foo;
test["catch"];
test["catch"].foo;

View File

@@ -1 +1,6 @@
obj["x"] = 2;
test.catch;
test.catch["foo"];
test["catch"];
test["catch"]["foo"];

View File

@@ -1,3 +1,8 @@
"use strict";
obj.x = 2;
test["catch"];
test["catch"].foo;
test["catch"];
test["catch"].foo;