add classesFastSuper optional transformer - fixes #451
This commit is contained in:
25
test/fixtures/transformation/optional-classes-fast-super/accessing-super-class/actual.js
vendored
Normal file
25
test/fixtures/transformation/optional-classes-fast-super/accessing-super-class/actual.js
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
class Test extends Foo {
|
||||
constructor() {
|
||||
woops.super.test();
|
||||
super();
|
||||
super.test();
|
||||
|
||||
super(...arguments);
|
||||
super("test", ...arguments);
|
||||
|
||||
super.test(...arguments);
|
||||
super.test("test", ...arguments);
|
||||
}
|
||||
|
||||
test() {
|
||||
super();
|
||||
super(...arguments);
|
||||
super("test", ...arguments);
|
||||
}
|
||||
|
||||
static foo() {
|
||||
super();
|
||||
super(...arguments);
|
||||
super("test", ...arguments);
|
||||
}
|
||||
}
|
||||
50
test/fixtures/transformation/optional-classes-fast-super/accessing-super-class/expected.js
vendored
Normal file
50
test/fixtures/transformation/optional-classes-fast-super/accessing-super-class/expected.js
vendored
Normal file
@@ -0,0 +1,50 @@
|
||||
"use strict";
|
||||
|
||||
var _slice = Array.prototype.slice;
|
||||
var _inherits = function (child, parent) {
|
||||
if (typeof parent !== "function" && parent !== null) {
|
||||
throw new TypeError("Super expression must either be null or a function, not " + typeof parent);
|
||||
}
|
||||
child.prototype = Object.create(parent && parent.prototype, {
|
||||
constructor: {
|
||||
value: child,
|
||||
enumerable: false,
|
||||
writable: true,
|
||||
configurable: true
|
||||
}
|
||||
});
|
||||
if (parent) child.__proto__ = parent;
|
||||
};
|
||||
|
||||
var Test = (function (Foo) {
|
||||
var Test = function Test() {
|
||||
var _Foo$prototype$test, _Foo$prototype$test2;
|
||||
woops["super"].test();
|
||||
Foo.call(this);
|
||||
Foo.prototype.test.call(this);
|
||||
|
||||
Foo.call.apply(Foo, [this].concat(_slice.call(arguments)));
|
||||
Foo.call.apply(Foo, [this, "test"].concat(_slice.call(arguments)));
|
||||
|
||||
(_Foo$prototype$test = Foo.prototype.test).call.apply(_Foo$prototype$test, [this].concat(_slice.call(arguments)));
|
||||
(_Foo$prototype$test2 = Foo.prototype.test).call.apply(_Foo$prototype$test2, [this, "test"].concat(_slice.call(arguments)));
|
||||
};
|
||||
|
||||
_inherits(Test, Foo);
|
||||
|
||||
Test.prototype.test = function () {
|
||||
var _Foo$prototype$test3, _Foo$prototype$test4;
|
||||
Foo.prototype.test.call(this);
|
||||
(_Foo$prototype$test3 = Foo.prototype.test).call.apply(_Foo$prototype$test3, [this].concat(_slice.call(arguments)));
|
||||
(_Foo$prototype$test4 = Foo.prototype.test).call.apply(_Foo$prototype$test4, [this, "test"].concat(_slice.call(arguments)));
|
||||
};
|
||||
|
||||
Test.foo = function () {
|
||||
var _Foo$foo, _Foo$foo2;
|
||||
Foo.foo.call(this);
|
||||
(_Foo$foo = Foo.foo).call.apply(_Foo$foo, [this].concat(_slice.call(arguments)));
|
||||
(_Foo$foo2 = Foo.foo).call.apply(_Foo$foo2, [this, "test"].concat(_slice.call(arguments)));
|
||||
};
|
||||
|
||||
return Test;
|
||||
})(Foo);
|
||||
@@ -0,0 +1,6 @@
|
||||
class Test extends Foo {
|
||||
constructor() {
|
||||
super.test;
|
||||
super.test.whatever;
|
||||
}
|
||||
}
|
||||
27
test/fixtures/transformation/optional-classes-fast-super/accessing-super-properties/expected.js
vendored
Normal file
27
test/fixtures/transformation/optional-classes-fast-super/accessing-super-properties/expected.js
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
"use strict";
|
||||
|
||||
var _inherits = function (child, parent) {
|
||||
if (typeof parent !== "function" && parent !== null) {
|
||||
throw new TypeError("Super expression must either be null or a function, not " + typeof parent);
|
||||
}
|
||||
child.prototype = Object.create(parent && parent.prototype, {
|
||||
constructor: {
|
||||
value: child,
|
||||
enumerable: false,
|
||||
writable: true,
|
||||
configurable: true
|
||||
}
|
||||
});
|
||||
if (parent) child.__proto__ = parent;
|
||||
};
|
||||
|
||||
var Test = (function (Foo) {
|
||||
var Test = function Test() {
|
||||
Foo.prototype.test;
|
||||
Foo.prototype.test.whatever;
|
||||
};
|
||||
|
||||
_inherits(Test, Foo);
|
||||
|
||||
return Test;
|
||||
})(Foo);
|
||||
10
test/fixtures/transformation/optional-classes-fast-super/calling-super-properties/actual.js
vendored
Normal file
10
test/fixtures/transformation/optional-classes-fast-super/calling-super-properties/actual.js
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
class Test extends Foo {
|
||||
constructor() {
|
||||
super.test.whatever();
|
||||
super.test();
|
||||
}
|
||||
|
||||
static test() {
|
||||
return super.wow();
|
||||
}
|
||||
}
|
||||
31
test/fixtures/transformation/optional-classes-fast-super/calling-super-properties/expected.js
vendored
Normal file
31
test/fixtures/transformation/optional-classes-fast-super/calling-super-properties/expected.js
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
"use strict";
|
||||
|
||||
var _inherits = function (child, parent) {
|
||||
if (typeof parent !== "function" && parent !== null) {
|
||||
throw new TypeError("Super expression must either be null or a function, not " + typeof parent);
|
||||
}
|
||||
child.prototype = Object.create(parent && parent.prototype, {
|
||||
constructor: {
|
||||
value: child,
|
||||
enumerable: false,
|
||||
writable: true,
|
||||
configurable: true
|
||||
}
|
||||
});
|
||||
if (parent) child.__proto__ = parent;
|
||||
};
|
||||
|
||||
var Test = (function (Foo) {
|
||||
var Test = function Test() {
|
||||
Foo.prototype.test.whatever();
|
||||
Foo.prototype.test.call(this);
|
||||
};
|
||||
|
||||
_inherits(Test, Foo);
|
||||
|
||||
Test.test = function () {
|
||||
return Foo.wow.call(this);
|
||||
};
|
||||
|
||||
return Test;
|
||||
})(Foo);
|
||||
3
test/fixtures/transformation/optional-classes-fast-super/options.json
vendored
Normal file
3
test/fixtures/transformation/optional-classes-fast-super/options.json
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"optional": ["classesFastSuper"]
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
class BaseController extends Chaplin.Controller {
|
||||
|
||||
}
|
||||
|
||||
class BaseController2 extends Chaplin.Controller.Another {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
"use strict";
|
||||
|
||||
var _inherits = function (child, parent) {
|
||||
if (typeof parent !== "function" && parent !== null) {
|
||||
throw new TypeError("Super expression must either be null or a function, not " + typeof parent);
|
||||
}
|
||||
child.prototype = Object.create(parent && parent.prototype, {
|
||||
constructor: {
|
||||
value: child,
|
||||
enumerable: false,
|
||||
writable: true,
|
||||
configurable: true
|
||||
}
|
||||
});
|
||||
if (parent) child.__proto__ = parent;
|
||||
};
|
||||
|
||||
var BaseController = (function (_Chaplin$Controller) {
|
||||
var BaseController = function BaseController() {
|
||||
if (Chaplin.Controller != null) {
|
||||
Chaplin.Controller.apply(this, arguments);
|
||||
}
|
||||
};
|
||||
|
||||
_inherits(BaseController, _Chaplin$Controller);
|
||||
|
||||
return BaseController;
|
||||
})(Chaplin.Controller);
|
||||
|
||||
var BaseController2 = (function (_Chaplin$Controller$Another) {
|
||||
var BaseController2 = function BaseController2() {
|
||||
if (Chaplin.Controller.Another != null) {
|
||||
Chaplin.Controller.Another.apply(this, arguments);
|
||||
}
|
||||
};
|
||||
|
||||
_inherits(BaseController2, _Chaplin$Controller$Another);
|
||||
|
||||
return BaseController2;
|
||||
})(Chaplin.Controller.Another);
|
||||
1
test/fixtures/transformation/optional-classes-fast-super/super-class/actual.js
vendored
Normal file
1
test/fixtures/transformation/optional-classes-fast-super/super-class/actual.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
class Test extends Foo { }
|
||||
28
test/fixtures/transformation/optional-classes-fast-super/super-class/expected.js
vendored
Normal file
28
test/fixtures/transformation/optional-classes-fast-super/super-class/expected.js
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
"use strict";
|
||||
|
||||
var _inherits = function (child, parent) {
|
||||
if (typeof parent !== "function" && parent !== null) {
|
||||
throw new TypeError("Super expression must either be null or a function, not " + typeof parent);
|
||||
}
|
||||
child.prototype = Object.create(parent && parent.prototype, {
|
||||
constructor: {
|
||||
value: child,
|
||||
enumerable: false,
|
||||
writable: true,
|
||||
configurable: true
|
||||
}
|
||||
});
|
||||
if (parent) child.__proto__ = parent;
|
||||
};
|
||||
|
||||
var Test = (function (Foo) {
|
||||
var Test = function Test() {
|
||||
if (Foo != null) {
|
||||
Foo.apply(this, arguments);
|
||||
}
|
||||
};
|
||||
|
||||
_inherits(Test, Foo);
|
||||
|
||||
return Test;
|
||||
})(Foo);
|
||||
5
test/fixtures/transformation/optional-classes-fast-super/super-function-fallback/actual.js
vendored
Normal file
5
test/fixtures/transformation/optional-classes-fast-super/super-function-fallback/actual.js
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
class Test {
|
||||
constructor() {
|
||||
super.hasOwnProperty("test");
|
||||
}
|
||||
}
|
||||
5
test/fixtures/transformation/optional-classes-fast-super/super-function-fallback/expected.js
vendored
Normal file
5
test/fixtures/transformation/optional-classes-fast-super/super-function-fallback/expected.js
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
"use strict";
|
||||
|
||||
var Test = function Test() {
|
||||
Function.prototype.hasOwnProperty.call(this, "test");
|
||||
};
|
||||
Reference in New Issue
Block a user