Compare commits

..

10 Commits

Author SHA1 Message Date
Sebastian McKenzie
bb19649af8 v4.3.0 2015-02-18 13:15:45 +11:00
Sebastian McKenzie
692262df1b fix linting errors 2015-02-18 13:14:06 +11:00
Sebastian McKenzie
067047da34 update commonStandard tests to commonStrict 2015-02-18 13:10:25 +11:00
Sebastian McKenzie
1c5d169b1e 4.2.1 2015-02-18 13:08:36 +11:00
Sebastian McKenzie
3f82b4ec72 remove commonStandard module formatter and make it the default behaviour of all the strict module formatters 2015-02-18 13:08:25 +11:00
Sebastian McKenzie
9c6e632021 Merge pull request #785 from babel/fn-name
Set Function.name for funcs in variables and properties as per spec.
2015-02-18 11:49:52 +11:00
Sebastian McKenzie
45553f1fb7 v4.2.1 2015-02-18 11:37:47 +11:00
Sebastian McKenzie
f228edbb84 add auxiliary comment to let scoping closure flow control - fixes #819 2015-02-18 11:35:57 +11:00
Sebastian McKenzie
64e657e53d 4.2.0 2015-02-18 11:33:58 +11:00
Ingvar Stepanyan
17e65cc772 Set Function.name for funcs in variables and properties as per spec.
Implements correct Function.name for cases like following:
 * `var x = function () { ... }`
 * `var obj = {prop: function () { ... }}`
2015-02-15 23:43:17 +02:00
24 changed files with 165 additions and 32 deletions

View File

@@ -13,6 +13,16 @@ _Note: Gaps between patch versions are faulty/broken releases._
See [CHANGELOG - 6to5](CHANGELOG-6to5.md) for the pre-4.0.0 version changelog.
## 4.3.0
* **Breaking Change**
* Remove `commonStandard` module formatter and make it the default behaviour of all the strict module formatters.
## 4.2.1
* **Polish**
* Add auxiliary comment to let scoping closure flow control.
## 4.2.0
* **Polish**

View File

@@ -60,7 +60,8 @@ File.helpers = [
"object-destructuring-empty",
"temporal-undefined",
"temporal-assert-defined",
"tail-call"
"tail-call",
"self-global"
];
File.validOptions = [

View File

@@ -4,6 +4,7 @@ var util = require("../../util");
module.exports = function (Parent) {
var Constructor = function () {
this.noInteropRequireImport = true;
this.noInteropRequireExport = true;
Parent.apply(this, arguments);
};

View File

@@ -1,13 +0,0 @@
"use strict";
module.exports = CommonStandardFormatter;
var CommonStrictFormatter = require("./common-strict");
var util = require("../../util");
function CommonStandardFormatter() {
this.noInteropRequireImport = true;
CommonStrictFormatter.apply(this, arguments);
}
util.inherits(CommonStandardFormatter, CommonStrictFormatter);

View File

@@ -1,11 +1,10 @@
module.exports = {
commonStandard: require("./common-standard"),
commonStrict: require("./common-strict"),
amdStrict: require("./amd-strict"),
umdStrict: require("./umd-strict"),
common: require("./common"),
system: require("./system"),
ignore: require("./ignore"),
amd: require("./amd"),
umd: require("./umd")
commonStrict: require("./common-strict"),
amdStrict: require("./amd-strict"),
umdStrict: require("./umd-strict"),
common: require("./common"),
system: require("./system"),
ignore: require("./ignore"),
amd: require("./amd"),
umd: require("./umd")
};

View File

@@ -0,0 +1,7 @@
(function () {
function GET_OUTER_ID() {
return ID;
}
return FUNCTION;
})()

View File

@@ -546,14 +546,16 @@ BlockScoping.prototype.buildHas = function (ret, call) {
if (cases.length === 1) {
var single = cases[0];
body.push(t.ifStatement(
body.push(this.file.attachAuxiliaryComment(t.ifStatement(
t.binaryExpression("===", ret, single.test),
single.consequent[0]
));
)));
} else {
body.push(t.switchStatement(ret, cases));
body.push(this.file.attachAuxiliaryComment(t.switchStatement(ret, cases)));
}
} else {
if (has.hasReturn) body.push(retCheck);
if (has.hasReturn) {
body.push(this.file.attachAuxiliaryComment(retCheck));
}
}
};

View File

@@ -91,6 +91,7 @@ module.exports = {
"spec.typeofSymbol": require("./spec/typeof-symbol"),
"spec.undefinedToVoid": require("./spec/undefined-to-void"),
"spec.functionName": require("./spec/function-name"),
_moduleFormatter: require("./internal/module-formatter"),

View File

@@ -0,0 +1,53 @@
"use strict";
var util = require("../../../util");
var t = require("../../../types");
var propertyFunctionVisitor = {
enter: function (node, parent, scope, state) {
if (t.isReferencedIdentifier(node, parent, { name: state.name }) && scope.getBindingIdentifier(node.name) === state.binding) {
return state.getOuter();
}
}
};
exports.FunctionExpression = function (node, parent, scope, file) {
if (node.id) return;
var id;
if (t.isProperty(parent)) {
id = parent.key;
} else if (t.isVariableDeclarator(parent)) {
id = parent.id;
} else {
return;
}
var binding = scope.getBindingIdentifier(id.name);
var outerId, selfGlobalId;
scope.traverse(node, propertyFunctionVisitor, {
name: id.name,
binding: binding,
getOuter: function () {
if (!binding) {
return t.memberExpression(
selfGlobalId || (selfGlobalId = file.addHelper("self-global")),
id
);
}
return t.callExpression(
outerId || (outerId = scope.generateUidIdentifier("getOuter")),
[]
);
}
});
node.id = id;
if (outerId) {
return util.template("named-func", {
GET_OUTER_ID: outerId,
ID: id,
FUNCTION: node
});
}
};
exports.optional = true;

View File

@@ -1,7 +1,7 @@
{
"name": "babel",
"description": "Turn ES6 code into readable vanilla ES5 with source maps",
"version": "4.2.0",
"version": "4.3.0",
"author": "Sebastian McKenzie <sebmck@gmail.com>",
"homepage": "https://babeljs.io/",
"repository": "babel/babel",

View File

@@ -1,7 +1,7 @@
{
"name": "babel-runtime",
"description": "babel selfContained runtime",
"version": "4.1.1",
"version": "4.2.1",
"repository": "babel/babel",
"author": "Sebastian McKenzie <sebmck@gmail.com>"
}

View File

@@ -1,3 +0,0 @@
{
"modules": "commonStandard"
}

View File

@@ -0,0 +1,3 @@
{
"modules": "commonStrict"
}

View File

@@ -0,0 +1,27 @@
var obj = {
f: function () {
(function f() {
console.log(f);
})();
},
g: function () {
console.log(g);
},
h: function () {
console.log(h);
},
m: function () {
doSmth();
}
};
var f = function () {
console.log(f, g);
};
var g = function () {
doSmth();
};

View File

@@ -0,0 +1,42 @@
"use strict";
var _selfGlobal = typeof global === "undefined" ? self : global;
var obj = {
f: function f() {
(function f() {
console.log(f);
})();
},
g: (function () {
function _getOuter() {
return g;
}
return function g() {
console.log(_getOuter());
};
})(),
h: function h() {
console.log(_selfGlobal.h);
},
m: function m() {
doSmth();
}
};
var f = (function () {
function _getOuter() {
return f;
}
return function f() {
console.log(_getOuter(), g);
};
})();
var g = function g() {
doSmth();
};

View File

@@ -0,0 +1,3 @@
{
"whitelist": ["spec.functionName"]
}