add optional protoToAssign transformer
This commit is contained in:
5
test/fixtures/transformation/optional-proto-to-assign/assignment-expression/actual.js
vendored
Normal file
5
test/fixtures/transformation/optional-proto-to-assign/assignment-expression/actual.js
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
console.log(foo.__proto__ = bar);
|
||||
|
||||
console.log(foo[bar].__proto__ = bar);
|
||||
|
||||
console.log(foo[bar()].__proto__ = bar);
|
||||
18
test/fixtures/transformation/optional-proto-to-assign/assignment-expression/expected.js
vendored
Normal file
18
test/fixtures/transformation/optional-proto-to-assign/assignment-expression/expected.js
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
"use strict";
|
||||
|
||||
var _foo, _foo$bar, _foo2;
|
||||
var _defaults = function (obj, defaults) {
|
||||
for (var key in defaults) {
|
||||
if (obj[key] === undefined) {
|
||||
obj[key] = defaults[key];
|
||||
}
|
||||
}
|
||||
|
||||
return obj;
|
||||
};
|
||||
|
||||
console.log((_foo = foo, _defaults(_foo, bar), _foo));
|
||||
|
||||
console.log((_foo$bar = foo[bar], _defaults(_foo$bar, bar), _foo$bar));
|
||||
|
||||
console.log((_foo2 = foo[bar()], _defaults(_foo2, bar), _foo2));
|
||||
1
test/fixtures/transformation/optional-proto-to-assign/assignment-statement/actual.js
vendored
Normal file
1
test/fixtures/transformation/optional-proto-to-assign/assignment-statement/actual.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
obj.__proto__ = bar;
|
||||
13
test/fixtures/transformation/optional-proto-to-assign/assignment-statement/expected.js
vendored
Normal file
13
test/fixtures/transformation/optional-proto-to-assign/assignment-statement/expected.js
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
"use strict";
|
||||
|
||||
var _defaults = function (obj, defaults) {
|
||||
for (var key in defaults) {
|
||||
if (obj[key] === undefined) {
|
||||
obj[key] = defaults[key];
|
||||
}
|
||||
}
|
||||
|
||||
return obj;
|
||||
};
|
||||
|
||||
_defaults(obj, bar);
|
||||
3
test/fixtures/transformation/optional-proto-to-assign/class/actual.js
vendored
Normal file
3
test/fixtures/transformation/optional-proto-to-assign/class/actual.js
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
class Foo extends Bar {
|
||||
|
||||
}
|
||||
36
test/fixtures/transformation/optional-proto-to-assign/class/expected.js
vendored
Normal file
36
test/fixtures/transformation/optional-proto-to-assign/class/expected.js
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
"use strict";
|
||||
|
||||
var _defaults = function (obj, defaults) {
|
||||
for (var key in defaults) {
|
||||
if (obj[key] === undefined) {
|
||||
obj[key] = defaults[key];
|
||||
}
|
||||
}
|
||||
|
||||
return obj;
|
||||
};
|
||||
|
||||
var _inherits = function (child, parent) {
|
||||
child.prototype = Object.create(parent && parent.prototype, {
|
||||
constructor: {
|
||||
value: child,
|
||||
enumerable: false,
|
||||
writable: true,
|
||||
configurable: true
|
||||
}
|
||||
});
|
||||
if (parent) _defaults(child, parent);
|
||||
};
|
||||
|
||||
var Foo = (function () {
|
||||
var _Bar = Bar;
|
||||
var Foo = function Foo() {
|
||||
if (_Bar) {
|
||||
_Bar.apply(this, arguments);
|
||||
}
|
||||
};
|
||||
|
||||
_inherits(Foo, _Bar);
|
||||
|
||||
return Foo;
|
||||
})();
|
||||
13
test/fixtures/transformation/optional-proto-to-assign/object-literal/actual.js
vendored
Normal file
13
test/fixtures/transformation/optional-proto-to-assign/object-literal/actual.js
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
var foo = {
|
||||
__proto__: bar
|
||||
};
|
||||
|
||||
var foo = {
|
||||
bar: "foo",
|
||||
__proto__: bar
|
||||
};
|
||||
|
||||
var foo = {
|
||||
__proto__: bar,
|
||||
bar: "foo"
|
||||
};
|
||||
10
test/fixtures/transformation/optional-proto-to-assign/object-literal/expected.js
vendored
Normal file
10
test/fixtures/transformation/optional-proto-to-assign/object-literal/expected.js
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
"use strict";
|
||||
|
||||
var foo = Object.assign({}, bar);
|
||||
|
||||
var foo = Object.assign({}, bar, {
|
||||
bar: "foo" });
|
||||
|
||||
var foo = Object.assign({}, bar, {
|
||||
bar: "foo"
|
||||
});
|
||||
3
test/fixtures/transformation/optional-proto-to-assign/options.json
vendored
Normal file
3
test/fixtures/transformation/optional-proto-to-assign/options.json
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"optional": ["protoToAssign"]
|
||||
}
|
||||
Reference in New Issue
Block a user