Skip to content

Commit

Permalink
Change parameter order of defineAccessor
Browse files Browse the repository at this point in the history
  • Loading branch information
SuperSodaSea committed Nov 29, 2022
1 parent 16758f3 commit 1fd56a3
Show file tree
Hide file tree
Showing 10 changed files with 19 additions and 19 deletions.
2 changes: 1 addition & 1 deletion packages/babel-helpers/src/helpers-generated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export default Object.freeze({
),
defineAccessor: helper(
"7.20.6",
"export default function _defineAccessor(obj,key,type,fn){var desc={configurable:!0,enumerable:!0};return desc[type]=fn,Object.defineProperty(obj,key,desc)}",
"export default function _defineAccessor(type,obj,key,fn){var desc={configurable:!0,enumerable:!0};return desc[type]=fn,Object.defineProperty(obj,key,desc)}",
),
iterableToArrayLimit: helper(
"7.0.0-beta.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/babel-helpers/src/helpers/defineAccessor.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* @minVersion 7.20.6 */

export default function _defineAccessor(obj, key, type, fn) {
export default function _defineAccessor(type, obj, key, fn) {
var desc = { configurable: true, enumerable: true };
// type should be "get" or "set"
desc[type] = fn;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,18 +78,18 @@ export default declare((api, options: Options) => {

if (computedProps.length === 1) {
return t.callExpression(state.addHelper("defineAccessor"), [
t.stringLiteral(prop.kind),
initPropExpression,
key,
t.stringLiteral(prop.kind),
getValue(prop),
]);
} else {
body.push(
t.expressionStatement(
t.callExpression(state.addHelper("defineAccessor"), [
t.stringLiteral(prop.kind),
t.cloneNode(objId),
key,
t.stringLiteral(prop.kind),
getValue(prop),
]),
),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
var _obj;
var obj = (_obj = {}, babelHelpers.defineAccessor(_obj, foobar, "get", function () {
var obj = (_obj = {}, babelHelpers.defineAccessor("get", _obj, foobar, function () {
return "foobar";
}), babelHelpers.defineAccessor(_obj, foobar, "set", function (x) {
}), babelHelpers.defineAccessor("set", _obj, foobar, function (x) {
console.log(x);
}), babelHelpers.defineAccessor(_obj, "test", "get", function () {
}), babelHelpers.defineAccessor("get", _obj, "test", function () {
return "regular getter after computed property";
}), babelHelpers.defineAccessor(_obj, "test", "set", function (x) {
}), babelHelpers.defineAccessor("set", _obj, "test", function (x) {
console.log(x);
}), _obj);
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
var obj = babelHelpers.defineAccessor({}, "x" + foo, "get", function () {
var obj = babelHelpers.defineAccessor("get", {}, "x" + foo, function () {
return "heh";
});
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
var _foo;
var k = Symbol();
var foo = (_foo = {}, _foo[Symbol.iterator] = "foobar", babelHelpers.defineAccessor(_foo, k, "get", function () {
var foo = (_foo = {}, _foo[Symbol.iterator] = "foobar", babelHelpers.defineAccessor("get", _foo, k, function () {
return k;
}), _foo);
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
var _obj;
var obj = (_obj = {}, babelHelpers.defineAccessor(_obj, foobar, "get", function () {
var obj = (_obj = {}, babelHelpers.defineAccessor("get", _obj, foobar, function () {
return "foobar";
}), babelHelpers.defineAccessor(_obj, foobar, "set", function (x) {
}), babelHelpers.defineAccessor("set", _obj, foobar, function (x) {
console.log(x);
}), babelHelpers.defineAccessor(_obj, "test", "get", function () {
}), babelHelpers.defineAccessor("get", _obj, "test", function () {
return "regular getter after computed property";
}), babelHelpers.defineAccessor(_obj, "test", "set", function (x) {
}), babelHelpers.defineAccessor("set", _obj, "test", function (x) {
console.log(x);
}), _obj);
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
var _a, _b, _x;
var a = (_a = {}, babelHelpers.defineAccessor(_a, "x", "get", function () {
var a = (_a = {}, babelHelpers.defineAccessor("get", _a, "x", function () {
return 0;
}), babelHelpers.defineProperty(_a, "y", 1), _a);
var b = (_b = {}, babelHelpers.defineAccessor(_b, "x", "get", function () {
var b = (_b = {}, babelHelpers.defineAccessor("get", _b, "x", function () {
return 0;
}), babelHelpers.defineProperty(_b, "x", 1), _b);
var x = (_x = {
x
}, babelHelpers.defineAccessor(_x, "x", "get", function () {
}, babelHelpers.defineAccessor("get", _x, "x", function () {
return 0;
}), babelHelpers.defineProperty(_x, "x", x), _x);
x.x = 1;
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
var obj = babelHelpers.defineAccessor({}, "x" + foo, "get", function () {
var obj = babelHelpers.defineAccessor("get", {}, "x" + foo, function () {
return "heh";
});
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
var _foo;
var k = Symbol();
var foo = (_foo = {}, babelHelpers.defineProperty(_foo, Symbol.iterator, "foobar"), babelHelpers.defineAccessor(_foo, k, "get", function () {
var foo = (_foo = {}, babelHelpers.defineProperty(_foo, Symbol.iterator, "foobar"), babelHelpers.defineAccessor("get", _foo, k, function () {
return k;
}), _foo);

0 comments on commit 1fd56a3

Please sign in to comment.