diff --git a/lib/6to5/templates/class.js b/lib/6to5/templates/class.js index 56e8aaa6e9..0f488ac301 100644 --- a/lib/6to5/templates/class.js +++ b/lib/6to5/templates/class.js @@ -1,7 +1,7 @@ (function () { - function CLASS_NAME() { + var CLASS_NAME = function CLASS_NAME() { - } + }; return CLASS_NAME; })() diff --git a/lib/6to5/transformers/classes.js b/lib/6to5/transformers/classes.js index ec94d049e7..f207a9c8ba 100644 --- a/lib/6to5/transformers/classes.js +++ b/lib/6to5/transformers/classes.js @@ -22,7 +22,19 @@ var getMemberExpressionObject = function (node) { var buildClass = function (node, generateUid) { var superName = node.superClass; - var className = node.id || b.identifier("Anonymous"); + var className = node.id; + + if (superName) { + if (superName.type === "Literal" && superName.value === null) { + superName = null; + } + } + + var noName = false; + if (!className) { + className = b.identifier(generateUid("_class")); + noName = true; + } var superClassArgument = node.superClass; var superClassCallee = node.superClass; @@ -43,6 +55,10 @@ var buildClass = function (node, generateUid) { var block = container.callee.body; var body = block.body; + if (noName) { + body[0].declarations[0].init.id = null; + } + var returnStatement = body.pop(); if (superName) { @@ -74,7 +90,7 @@ var buildClassBody = function (body, className, superName, node) { var staticMutatorMap = {}; var hasConstructor = false; - var construct = body[0]; + var construct = body[0].declarations[0].init; var classBody = node.body.body; _.each(classBody, function (node) { @@ -145,7 +161,7 @@ var superIdentifier = function (superName, methodNode, methodName, node, parent) node = b.memberExpression(node, b.identifier(methodName), false); return b.memberExpression(node, b.identifier("call"), false); } - } else if (parent.type === "MemberExpression") { + } else if (parent.type === "MemberExpression" && !methodNode.static) { // super.test -> ClassName.prototype.test return b.memberExpression(superName, b.identifier("prototype"), false); } else { diff --git a/test/fixtures/bin/6to5/dir --out-dir --source-maps-inline/out-files/lib/bar/bar.js b/test/fixtures/bin/6to5/dir --out-dir --source-maps-inline/out-files/lib/bar/bar.js index c74c6a104b..1bf5b4ff3b 100644 --- a/test/fixtures/bin/6to5/dir --out-dir --source-maps-inline/out-files/lib/bar/bar.js +++ b/test/fixtures/bin/6to5/dir --out-dir --source-maps-inline/out-files/lib/bar/bar.js @@ -1,5 +1,5 @@ var Test = function() { - function Test() {} + var Test = function Test() {}; return Test; }(); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibGliL2Jhci9iYXIuanMiLCJzb3VyY2VzIjpbInNyYy9iYXIvYmFyLmpzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJJQUFNLENBQUMsQ0FBQyxDQUFDO1dBQUgsQ0FBQyxDQUFDLENBQUM7U0FBSCxDQUFDLENBQUMsQ0FBQyIsInNvdXJjZXNDb250ZW50IjpbImNsYXNzIFRlc3Qge1xuXG59Il19 +//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibGliL2Jhci9iYXIuanMiLCJzb3VyY2VzIjpbInNyYy9iYXIvYmFyLmpzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJJQUFNLENBQUMsQ0FBQyxDQUFDO01BQUgsQ0FBQyxDQUFDLENBQUMsYUFBSCxDQUFDLENBQUMsQ0FBQztTQUFILENBQUMsQ0FBQyxDQUFDIiwic291cmNlc0NvbnRlbnQiOlsiY2xhc3MgVGVzdCB7XG5cbn0iXX0= diff --git a/test/fixtures/bin/6to5/dir --out-dir --source-maps/out-files/lib/bar/bar.js b/test/fixtures/bin/6to5/dir --out-dir --source-maps/out-files/lib/bar/bar.js index e07233acc3..b3f271de91 100644 --- a/test/fixtures/bin/6to5/dir --out-dir --source-maps/out-files/lib/bar/bar.js +++ b/test/fixtures/bin/6to5/dir --out-dir --source-maps/out-files/lib/bar/bar.js @@ -1,4 +1,4 @@ var Test = function() { - function Test() {} + var Test = function Test() {}; return Test; }(); diff --git a/test/fixtures/bin/6to5/dir --out-dir --source-maps/out-files/lib/bar/bar.js.map b/test/fixtures/bin/6to5/dir --out-dir --source-maps/out-files/lib/bar/bar.js.map index 5ab2c365f2..c105aa503e 100644 --- a/test/fixtures/bin/6to5/dir --out-dir --source-maps/out-files/lib/bar/bar.js.map +++ b/test/fixtures/bin/6to5/dir --out-dir --source-maps/out-files/lib/bar/bar.js.map @@ -1 +1 @@ -{"version":3,"file":"lib/bar/bar.js","sources":["src/bar/bar.js"],"names":[],"mappings":"IAAM,CAAC,CAAC,CAAC;WAAH,CAAC,CAAC,CAAC;SAAH,CAAC,CAAC,CAAC","sourcesContent":["class Test {\n\n}"]} +{"version":3,"file":"lib/bar/bar.js","sources":["src/bar/bar.js"],"names":[],"mappings":"IAAM,CAAC,CAAC,CAAC;MAAH,CAAC,CAAC,CAAC,aAAH,CAAC,CAAC,CAAC;SAAH,CAAC,CAAC,CAAC","sourcesContent":["class Test {\n\n}"]} diff --git a/test/fixtures/bin/6to5/dir --out-dir/out-files/lib/bar/bar.js b/test/fixtures/bin/6to5/dir --out-dir/out-files/lib/bar/bar.js index e07233acc3..b3f271de91 100644 --- a/test/fixtures/bin/6to5/dir --out-dir/out-files/lib/bar/bar.js +++ b/test/fixtures/bin/6to5/dir --out-dir/out-files/lib/bar/bar.js @@ -1,4 +1,4 @@ var Test = function() { - function Test() {} + var Test = function Test() {}; return Test; }(); diff --git a/test/fixtures/bin/6to5/filenames --out-file --source-maps-inline/out-files/script3.js b/test/fixtures/bin/6to5/filenames --out-file --source-maps-inline/out-files/script3.js index c4b4a4c281..a178b67b5c 100644 --- a/test/fixtures/bin/6to5/filenames --out-file --source-maps-inline/out-files/script3.js +++ b/test/fixtures/bin/6to5/filenames --out-file --source-maps-inline/out-files/script3.js @@ -1,9 +1,9 @@ var Test = function() { - function Test() {} + var Test = function Test() {}; return Test; }(); arr.map(function(x) { return x * MULTIPLIER; }); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInNjcmlwdC5qcyIsInNjcmlwdDIuanMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IklBQU0sQ0FBQyxDQUFDLENBQUM7V0FBSCxDQUFDLENBQUMsQ0FBQztTQUFILENBQUMsQ0FBQyxDQUFDOzs7QUNBVCxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDLFVBQUM7U0FBSyxFQUFFLEVBQUUsQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUM7Q0FBQyxDQUFDIiwiZmlsZSI6InNjcmlwdDMuanMiLCJzb3VyY2VzQ29udGVudCI6WyJjbGFzcyBUZXN0IHtcblxufSIsImFyci5tYXAoeCA9PiB4ICogTVVMVElQTElFUik7Il19 +//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInNjcmlwdC5qcyIsInNjcmlwdDIuanMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IklBQU0sQ0FBQyxDQUFDLENBQUM7TUFBSCxDQUFDLENBQUMsQ0FBQyxhQUFILENBQUMsQ0FBQyxDQUFDO1NBQUgsQ0FBQyxDQUFDLENBQUM7OztBQ0FULENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUMsVUFBQztTQUFLLEVBQUUsRUFBRSxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQztDQUFDLENBQUMiLCJmaWxlIjoic2NyaXB0My5qcyIsInNvdXJjZXNDb250ZW50IjpbImNsYXNzIFRlc3Qge1xuXG59IiwiYXJyLm1hcCh4ID0+IHggKiBNVUxUSVBMSUVSKTsiXX0= diff --git a/test/fixtures/bin/6to5/filenames --out-file --source-maps/out-files/script3.js b/test/fixtures/bin/6to5/filenames --out-file --source-maps/out-files/script3.js index 09f0396320..92cf41bd5a 100644 --- a/test/fixtures/bin/6to5/filenames --out-file --source-maps/out-files/script3.js +++ b/test/fixtures/bin/6to5/filenames --out-file --source-maps/out-files/script3.js @@ -1,5 +1,5 @@ var Test = function() { - function Test() {} + var Test = function Test() {}; return Test; }(); arr.map(function(x) { diff --git a/test/fixtures/bin/6to5/filenames --out-file --source-maps/out-files/script3.js.map b/test/fixtures/bin/6to5/filenames --out-file --source-maps/out-files/script3.js.map index 445d4e39b1..730b2f7ee8 100644 --- a/test/fixtures/bin/6to5/filenames --out-file --source-maps/out-files/script3.js.map +++ b/test/fixtures/bin/6to5/filenames --out-file --source-maps/out-files/script3.js.map @@ -1 +1 @@ -{"version":3,"sources":["script.js","script2.js"],"names":[],"mappings":"IAAM,CAAC,CAAC,CAAC;WAAH,CAAC,CAAC,CAAC;SAAH,CAAC,CAAC,CAAC;;;ACAT,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,UAAC;SAAK,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CAAC,CAAC","file":"script3.js","sourcesContent":["class Test {\n\n}","arr.map(x => x * MULTIPLIER);"]} +{"version":3,"sources":["script.js","script2.js"],"names":[],"mappings":"IAAM,CAAC,CAAC,CAAC;MAAH,CAAC,CAAC,CAAC,aAAH,CAAC,CAAC,CAAC;SAAH,CAAC,CAAC,CAAC;;;ACAT,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,UAAC;SAAK,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CAAC,CAAC","file":"script3.js","sourcesContent":["class Test {\n\n}","arr.map(x => x * MULTIPLIER);"]} diff --git a/test/fixtures/bin/6to5/filenames --out-file/out-files/script3.js b/test/fixtures/bin/6to5/filenames --out-file/out-files/script3.js index 09f0396320..92cf41bd5a 100644 --- a/test/fixtures/bin/6to5/filenames --out-file/out-files/script3.js +++ b/test/fixtures/bin/6to5/filenames --out-file/out-files/script3.js @@ -1,5 +1,5 @@ var Test = function() { - function Test() {} + var Test = function Test() {}; return Test; }(); arr.map(function(x) { diff --git a/test/fixtures/syntax/api/blacklist/expected.js b/test/fixtures/syntax/api/blacklist/expected.js index f84dd564d3..c8515d28fd 100644 --- a/test/fixtures/syntax/api/blacklist/expected.js +++ b/test/fixtures/syntax/api/blacklist/expected.js @@ -1,6 +1,6 @@ var Test = function () { - function Test() { + var Test = function Test() { arr.map(x => x * x); - } + }; return Test; }(); diff --git a/test/fixtures/syntax/classes/accessing-super-class/expected.js b/test/fixtures/syntax/classes/accessing-super-class/expected.js index 2d16b90ebb..5535b50c4a 100644 --- a/test/fixtures/syntax/classes/accessing-super-class/expected.js +++ b/test/fixtures/syntax/classes/accessing-super-class/expected.js @@ -1,57 +1,57 @@ var Test = function(Foo) { - function Test() { - woops.super.test(); - Foo.call(this); + var Test = function Test() { + woops.super.test(); + Foo.call(this); + Foo.prototype.test.call(this); + foob(Foo); + Foo.call.apply(Foo, [this].concat(Array.prototype.slice.call(arguments))); + Foo.call.apply(Foo, [this, "test"].concat(Array.prototype.slice.call(arguments))); + Foo.prototype.test.call.apply(Foo.prototype, [this].concat(Array.prototype.slice.call(arguments))); + + Foo.prototype.test.call.apply( + Foo.prototype, + [this, "test"].concat(Array.prototype.slice.call(arguments)) + ); + }; + + Test.prototype = Object.create(Foo.prototype, { + constructor: { + value: Test, + enumerable: false, + writable: true, + configurable: true + } + }); + + Test.__proto__ = Foo; + + Object.defineProperties(Test.prototype, { + test: { + writeable: true, + + value: function() { Foo.prototype.test.call(this); - foob(Foo); - Foo.call.apply(Foo, [this].concat(Array.prototype.slice.call(arguments))); - Foo.call.apply(Foo, [this, "test"].concat(Array.prototype.slice.call(arguments))); - Foo.prototype.test.call.apply(Foo.prototype, [this].concat(Array.prototype.slice.call(arguments))); + Foo.prototype.test.call.apply(Foo.prototype.test, [this].concat(Array.prototype.slice.call(arguments))); Foo.prototype.test.call.apply( - Foo.prototype, - [this, "test"].concat(Array.prototype.slice.call(arguments)) + Foo.prototype.test, + [this, "test"].concat(Array.prototype.slice.call(arguments)) ); + } } + }); - Test.prototype = Object.create(Foo.prototype, { - constructor: { - value: Test, - enumerable: false, - writable: true, - configurable: true - } - }); + Object.defineProperties(Test, { + foo: { + writeable: true, - Test.__proto__ = Foo; + value: function() { + Foo.foo.call(this); + Foo.foo.call.apply(Foo.foo, [this].concat(Array.prototype.slice.call(arguments))); + Foo.foo.call.apply(Foo.foo, [this, "test"].concat(Array.prototype.slice.call(arguments))); + } + } + }); - Object.defineProperties(Test.prototype, { - test: { - writeable: true, - - value: function() { - Foo.prototype.test.call(this); - Foo.prototype.test.call.apply(Foo.prototype.test, [this].concat(Array.prototype.slice.call(arguments))); - - Foo.prototype.test.call.apply( - Foo.prototype.test, - [this, "test"].concat(Array.prototype.slice.call(arguments)) - ); - } - } - }); - - Object.defineProperties(Test, { - foo: { - writeable: true, - - value: function() { - Foo.foo.call(this); - Foo.foo.call.apply(Foo.foo, [this].concat(Array.prototype.slice.call(arguments))); - Foo.foo.call.apply(Foo.foo, [this, "test"].concat(Array.prototype.slice.call(arguments))); - } - } - }); - - return Test; + return Test; }(Foo); diff --git a/test/fixtures/syntax/classes/accessing-super-properties/expected.js b/test/fixtures/syntax/classes/accessing-super-properties/expected.js index 4c028e72e3..dceca76b06 100644 --- a/test/fixtures/syntax/classes/accessing-super-properties/expected.js +++ b/test/fixtures/syntax/classes/accessing-super-properties/expected.js @@ -1,18 +1,18 @@ var Test = function(Foo) { - function Test() { - Foo.prototype.test; - Foo.prototype.test.whatever; + var Test = function Test() { + Foo.prototype.test; + Foo.prototype.test.whatever; + }; + + Test.prototype = Object.create(Foo.prototype, { + constructor: { + value: Test, + enumerable: false, + writable: true, + configurable: true } + }); - Test.prototype = Object.create(Foo.prototype, { - constructor: { - value: Test, - enumerable: false, - writable: true, - configurable: true - } - }); - - Test.__proto__ = Foo; - return Test; + Test.__proto__ = Foo; + return Test; }(Foo); diff --git a/test/fixtures/syntax/classes/calling-super-properties/actual.js b/test/fixtures/syntax/classes/calling-super-properties/actual.js index 2417f793dd..993109dc24 100644 --- a/test/fixtures/syntax/classes/calling-super-properties/actual.js +++ b/test/fixtures/syntax/classes/calling-super-properties/actual.js @@ -3,4 +3,8 @@ class Test extends Foo { super.test.whatever(); super.test(); } + + static test() { + return super.wow(); + } } diff --git a/test/fixtures/syntax/classes/calling-super-properties/expected.js b/test/fixtures/syntax/classes/calling-super-properties/expected.js index 35502a75ca..1bd9713d8f 100644 --- a/test/fixtures/syntax/classes/calling-super-properties/expected.js +++ b/test/fixtures/syntax/classes/calling-super-properties/expected.js @@ -1,16 +1,25 @@ var Test = function(Foo) { - function Test() { - Foo.prototype.test.whatever(); - Foo.prototype.test.call(this); + var Test = function Test() { + Foo.prototype.test.whatever(); + Foo.prototype.test.call(this); + }; + Test.prototype = Object.create(Foo.prototype, { + constructor: { + value: Test, + enumerable: false, + writable: true, + configurable: true } - Test.prototype = Object.create(Foo.prototype, { - constructor: { - value: Test, - enumerable: false, - writable: true, - configurable: true - } - }); - Test.__proto__ = Foo; - return Test; + }); + Test.__proto__ = Foo; + Object.defineProperties(Test, { + test: { + writeable: true, + + value: function() { + return Foo.wow.call(this); + } + } + }); + return Test; }(Foo); diff --git a/test/fixtures/syntax/classes/constructor/expected.js b/test/fixtures/syntax/classes/constructor/expected.js index 73c4d4f672..9fff13ac23 100644 --- a/test/fixtures/syntax/classes/constructor/expected.js +++ b/test/fixtures/syntax/classes/constructor/expected.js @@ -1,14 +1,14 @@ var Test = function () { - function Test() { + var Test = function Test() { this.state = "test"; - } + }; return Test; }(); var Foo = function(Bar) { - function Foo() { + var Foo = function Foo() { this.state = "test"; - } + }; Foo.prototype = Object.create(Bar.prototype, { constructor: { diff --git a/test/fixtures/syntax/classes/instance-getter-and-setter/expected.js b/test/fixtures/syntax/classes/instance-getter-and-setter/expected.js index 4ae42e0f88..17b381a1f2 100644 --- a/test/fixtures/syntax/classes/instance-getter-and-setter/expected.js +++ b/test/fixtures/syntax/classes/instance-getter-and-setter/expected.js @@ -1,6 +1,5 @@ var Test = function () { - function Test() { - } + var Test = function Test() { }; Object.defineProperties(Test.prototype, { test: { get: function () { diff --git a/test/fixtures/syntax/classes/instance-getter/expected.js b/test/fixtures/syntax/classes/instance-getter/expected.js index 0ff55736f6..30a11c3716 100644 --- a/test/fixtures/syntax/classes/instance-getter/expected.js +++ b/test/fixtures/syntax/classes/instance-getter/expected.js @@ -1,6 +1,5 @@ var Test = function () { - function Test() { - } + var Test = function Test() { }; Object.defineProperties(Test.prototype, { test: { get: function () { diff --git a/test/fixtures/syntax/classes/instance-method/expected.js b/test/fixtures/syntax/classes/instance-method/expected.js index 3945f41673..be895733ce 100644 --- a/test/fixtures/syntax/classes/instance-method/expected.js +++ b/test/fixtures/syntax/classes/instance-method/expected.js @@ -1,6 +1,5 @@ var Test = function () { - function Test() { - } + var Test = function Test() { }; Object.defineProperties(Test.prototype, { test: { writeable: true, diff --git a/test/fixtures/syntax/classes/instance-setter/expected.js b/test/fixtures/syntax/classes/instance-setter/expected.js index 56432ac1a1..4699c69f8a 100644 --- a/test/fixtures/syntax/classes/instance-setter/expected.js +++ b/test/fixtures/syntax/classes/instance-setter/expected.js @@ -1,6 +1,5 @@ var Test = function () { - function Test() { - } + var Test = function Test() { }; Object.defineProperties(Test.prototype, { test: { set: function (val) { diff --git a/test/fixtures/syntax/classes/plain-class/expected.js b/test/fixtures/syntax/classes/plain-class/expected.js index 8a1a129f99..4f3d4d5dab 100644 --- a/test/fixtures/syntax/classes/plain-class/expected.js +++ b/test/fixtures/syntax/classes/plain-class/expected.js @@ -1,5 +1,4 @@ var Test = function () { - function Test() { - } + var Test = function Test() { }; return Test; }(); diff --git a/test/fixtures/syntax/classes/statement/actual.js b/test/fixtures/syntax/classes/statement/actual.js index cc2a8fbc74..310a60a07c 100644 --- a/test/fixtures/syntax/classes/statement/actual.js +++ b/test/fixtures/syntax/classes/statement/actual.js @@ -4,4 +4,8 @@ var BaseView = class BaseView { } } -module.exports = BaseView; +var BaseView = class { + constructor() { + this.autoRender = true; + } +} diff --git a/test/fixtures/syntax/classes/statement/expected.js b/test/fixtures/syntax/classes/statement/expected.js index 11098452df..609f9b176b 100644 --- a/test/fixtures/syntax/classes/statement/expected.js +++ b/test/fixtures/syntax/classes/statement/expected.js @@ -1,9 +1,14 @@ var BaseView = function () { - function BaseView() { + var BaseView = function BaseView() { this.autoRender = true; - } + }; return BaseView; }(); -module.exports = BaseView; +var BaseView = function () { + var _class = function () { + this.autoRender = true; + }; + return _class; +}(); diff --git a/test/fixtures/syntax/classes/static/expected.js b/test/fixtures/syntax/classes/static/expected.js index 8892c37fb6..2d08f0f4c9 100644 --- a/test/fixtures/syntax/classes/static/expected.js +++ b/test/fixtures/syntax/classes/static/expected.js @@ -1,5 +1,5 @@ var A = function() { - function A() {} + var A = function A() {}; Object.defineProperties(A, { a: { diff --git a/test/fixtures/syntax/classes/super-class-member-expression/actual.js b/test/fixtures/syntax/classes/super-class-id-member-expression/actual.js similarity index 100% rename from test/fixtures/syntax/classes/super-class-member-expression/actual.js rename to test/fixtures/syntax/classes/super-class-id-member-expression/actual.js diff --git a/test/fixtures/syntax/classes/super-class-member-expression/expected.js b/test/fixtures/syntax/classes/super-class-id-member-expression/expected.js similarity index 87% rename from test/fixtures/syntax/classes/super-class-member-expression/expected.js rename to test/fixtures/syntax/classes/super-class-id-member-expression/expected.js index 1fbc1187f7..b5c03b4ff5 100644 --- a/test/fixtures/syntax/classes/super-class-member-expression/expected.js +++ b/test/fixtures/syntax/classes/super-class-id-member-expression/expected.js @@ -1,7 +1,7 @@ var BaseController = function (Chaplin) { - function BaseController() { + var BaseController = function BaseController() { Chaplin.Controller.apply(this, arguments); - } + }; BaseController.prototype = Object.create(Chaplin.Controller.prototype, { constructor: { value: BaseController, @@ -15,9 +15,9 @@ var BaseController = function (Chaplin) { }(Chaplin); var BaseController2 = function (Chaplin) { - function BaseController2() { + var BaseController2 = function BaseController2() { Chaplin.Controller.Another.apply(this, arguments); - } + }; BaseController2.prototype = Object.create(Chaplin.Controller.Another.prototype, { constructor: { value: BaseController2, diff --git a/test/fixtures/syntax/classes/super-class-non-identifiers/actual.js b/test/fixtures/syntax/classes/super-class-id-non-identifiers/actual.js similarity index 100% rename from test/fixtures/syntax/classes/super-class-non-identifiers/actual.js rename to test/fixtures/syntax/classes/super-class-id-non-identifiers/actual.js diff --git a/test/fixtures/syntax/classes/super-class-non-identifiers/expected.js b/test/fixtures/syntax/classes/super-class-id-non-identifiers/expected.js similarity index 90% rename from test/fixtures/syntax/classes/super-class-non-identifiers/expected.js rename to test/fixtures/syntax/classes/super-class-id-non-identifiers/expected.js index 592bf3b6d2..40b8fcc61b 100644 --- a/test/fixtures/syntax/classes/super-class-non-identifiers/expected.js +++ b/test/fixtures/syntax/classes/super-class-id-non-identifiers/expected.js @@ -1,7 +1,7 @@ var Q = function(_ref) { - function Q() { + var Q = function Q() { _ref.apply(this, arguments); - } + }; Q.prototype = Object.create(_ref.prototype, { constructor: { diff --git a/test/fixtures/syntax/classes/super-class/expected.js b/test/fixtures/syntax/classes/super-class/expected.js index cd513f41a8..53ea768531 100644 --- a/test/fixtures/syntax/classes/super-class/expected.js +++ b/test/fixtures/syntax/classes/super-class/expected.js @@ -1,7 +1,7 @@ var Test = function (Foo) { - function Test() { + var Test = function Test() { Foo.apply(this, arguments); - } + }; Test.prototype = Object.create(Foo.prototype, { constructor: { value: Test, diff --git a/test/fixtures/syntax/classes/super-fallback/actual.js b/test/fixtures/syntax/classes/super-function-fallback/actual.js similarity index 100% rename from test/fixtures/syntax/classes/super-fallback/actual.js rename to test/fixtures/syntax/classes/super-function-fallback/actual.js diff --git a/test/fixtures/syntax/classes/super-fallback/expected.js b/test/fixtures/syntax/classes/super-function-fallback/expected.js similarity index 74% rename from test/fixtures/syntax/classes/super-fallback/expected.js rename to test/fixtures/syntax/classes/super-function-fallback/expected.js index d234570e40..73cf9bb263 100644 --- a/test/fixtures/syntax/classes/super-fallback/expected.js +++ b/test/fixtures/syntax/classes/super-function-fallback/expected.js @@ -1,6 +1,6 @@ var Test = function () { - function Test() { + var Test = function Test() { Function.prototype.hasOwnProperty.call(this, "test"); - } + }; return Test; }(); diff --git a/test/fixtures/syntax/modules/exports-default/expected.js b/test/fixtures/syntax/modules/exports-default/expected.js index f8eebce331..57e6325b0d 100644 --- a/test/fixtures/syntax/modules/exports-default/expected.js +++ b/test/fixtures/syntax/modules/exports-default/expected.js @@ -8,15 +8,13 @@ exports.default = foo; exports.default = function () {} exports.default = function () { - function Anonymous() { - } - return Anonymous; + var _class = function() {}; + return _class; }(); exports.default = function foo () {} exports.default = function () { - function foo() { - } + var foo = function foo() {}; return foo; }(); diff --git a/test/fixtures/syntax/modules/exports-variable/expected.js b/test/fixtures/syntax/modules/exports-variable/expected.js index c4d9fb7c29..ed5e8ee4b6 100644 --- a/test/fixtures/syntax/modules/exports-variable/expected.js +++ b/test/fixtures/syntax/modules/exports-variable/expected.js @@ -25,8 +25,7 @@ var foo8; function foo7 () {} foo8 = function () { - function foo8() { - } + var foo8 = function foo8() {}; return foo8; }(); exports.foo8 = foo8; diff --git a/test/fixtures/syntax/source-maps/class/expected.js b/test/fixtures/syntax/source-maps/class/expected.js index 012e6129cd..7c7aeb0a7d 100644 --- a/test/fixtures/syntax/source-maps/class/expected.js +++ b/test/fixtures/syntax/source-maps/class/expected.js @@ -1,5 +1,5 @@ var Test = function() { - function Test() {} + var Test = function Test() {}; Object.defineProperties(Test.prototype, { bar: {