Compare commits

...

6 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
12 changed files with 31 additions and 31 deletions

View File

@@ -1,3 +1,8 @@
# 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`.

View File

@@ -44,7 +44,7 @@ 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

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

@@ -1,7 +1,7 @@
{
"name": "6to5",
"description": "Turn ES6 code into readable vanilla ES5 with source maps",
"version": "1.14.1",
"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;