Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
2268531
Support decorator 2023-11 normative updates (#16242)
JLHwung Jan 31, 2024
7ba06a6
fix: handle decorated async private method and generator (#16258)
JLHwung Feb 2, 2024
61b1d01
Remove logic for deprecated decorator versions from Babel 8 (#16256)
JLHwung Feb 4, 2024
aeb4dad
Preserve `static` on decorated private `accessor` (#16266)
nicolo-ribaudo Feb 7, 2024
8f8e96a
Reduce helper size for decorator 2023-11 (#16263)
liuxingbaoyu Feb 7, 2024
d903483
Do not use descriptors for private class elements (#16261)
nicolo-ribaudo Feb 7, 2024
52258a5
Do not define `access.get` for public setter decorators (#16265)
nicolo-ribaudo Feb 8, 2024
58a3fba
Handle symbol key class elements decoration (#16270)
JLHwung Feb 8, 2024
f02fa09
Do not consider `arguments` in a helper as a global reference (#16268)
nicolo-ribaudo Feb 8, 2024
f7293ab
Improve `toSetter` helper (#16269)
liuxingbaoyu Feb 14, 2024
fde1c0c
Fix class private properties when `privateFieldsAsProperties` (#16275)
liuxingbaoyu Feb 14, 2024
bbd4b6e
Fix decorator this memoization (#16279)
JLHwung Feb 14, 2024
62f2381
Reduce element decorator temp variables (#16280)
JLHwung Feb 14, 2024
4b2a181
test: add replacement-static-decorator-initializer-this test (#16288)
JLHwung Feb 16, 2024
0146fa6
Fix evaluation order of decorators with cached receiver (#16281)
nicolo-ribaudo Feb 18, 2024
69ae16e
Implement `noUninitializedPrivateFieldAccess` assumption (#16267)
nicolo-ribaudo Feb 19, 2024
9664174
Reduce decorator static property size (#16287)
liuxingbaoyu Feb 19, 2024
3dcd5da
Do not use `classPrivateMethodGet` (#16283)
liuxingbaoyu Feb 19, 2024
a9d65e8
More aggressively inline decorators in the static block (#16294)
nicolo-ribaudo Feb 21, 2024
b65d9b7
Move new private elements helper parameters (#16299)
liuxingbaoyu Feb 27, 2024
69e00ae
Avoid intermediate functions for private accessors with decs (#16306)
nicolo-ribaudo Feb 27, 2024
450c20e
Fix the support of `arguments` in private `get/set` method (#16307)
liuxingbaoyu Feb 27, 2024
526a624
Update fixtures (Windows)
babel-bot Feb 27, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Do not use classPrivateMethodGet (#16283)
classPrivateMethodGet
  • Loading branch information
liuxingbaoyu authored and nicolo-ribaudo committed Feb 27, 2024
commit 3dcd5daad90ff89d265ae1a963efbd4bbfb7bae3
13 changes: 8 additions & 5 deletions packages/babel-helper-create-class-features-plugin/src/fields.ts
Original file line number Diff line number Diff line change
Expand Up @@ -507,11 +507,14 @@ const privateNameHandlerSpec: Handler<PrivateNameState & Receiver> & Receiver =
t.cloneNode(getId),
]);
}
return t.callExpression(file.addHelper("classPrivateMethodGet"), [
this.receiver(member),
t.cloneNode(id),
t.cloneNode(methodId),
]);
return t.callExpression(
file.addHelper(
!process.env.BABEL_8_BREAKING && !newHelpers(file)
? "classPrivateMethodGet"
: "assertClassBrand",
),
[this.receiver(member), t.cloneNode(id), t.cloneNode(methodId)],
);
}
return t.callExpression(
process.env.BABEL_8_BREAKING || newHelpers(file)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class Derived extends Base {
babelHelpers.classPrivateMethodInitSpec(this, _Derived_brand);
}
static get(obj) {
return babelHelpers.classPrivateMethodGet(obj, _Derived_brand, _foo).call(obj);
return babelHelpers.assertClassBrand(obj, _Derived_brand, _foo).call(obj);
}
}
function _foo() {
Expand Down
1 change: 1 addition & 0 deletions packages/babel-helpers/src/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1728,6 +1728,7 @@ helpers.decorate = helper("7.1.5")`

`;

// TODO: Remove in Babel 8
helpers.classPrivateMethodGet = helper("7.1.6")`
import assertClassBrand from "assertClassBrand";
export default function _classPrivateMethodGet(receiver, privateSet, fn) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class Sub extends Base {
return 'bad';
}
publicMethod() {
return babelHelpers.classPrivateMethodGet(this, _Sub_brand, _privateMethod).call(this);
return babelHelpers.assertClassBrand(this, _Sub_brand, _privateMethod).call(this);
}
}
function _privateMethod() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ var _A_brand = /*#__PURE__*/new WeakSet();
class A {
constructor() {
babelHelpers.classPrivateMethodInitSpec(this, _A_brand);
babelHelpers.classPrivateMethodGet(this, _A_brand, _method).call(this);
babelHelpers.assertClassBrand(this, _A_brand, _method).call(this);
babelHelpers.classPrivateGetter(this, _A_brand, _get_getter);
babelHelpers.classPrivateSetter(this, _A_brand, _set_setter, 1);
babelHelpers.classPrivateGetter(this, _A_brand, _get_getset);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ var _Foo_brand = /*#__PURE__*/new WeakSet();
class Foo {
constructor() {
babelHelpers.classPrivateMethodInitSpec(this, _Foo_brand);
this.publicField = babelHelpers.classPrivateMethodGet(this, _Foo_brand, _privateMethod).call(this);
this.publicField = babelHelpers.assertClassBrand(this, _Foo_brand, _privateMethod).call(this);
}
}
function _privateMethod() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ class Cl {
babelHelpers.classPrivateMethodInitSpec(this, _Cl_brand);
}
test() {
return babelHelpers.classPrivateMethodGet(this, _Cl_brand, _foo).call(this);
return babelHelpers.assertClassBrand(this, _Cl_brand, _foo).call(this);
}
}
async function _foo() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ var _Cl_brand = /*#__PURE__*/new WeakSet();
class Cl {
constructor() {
babelHelpers.classPrivateMethodInitSpec(this, _Cl_brand);
babelHelpers.defineProperty(this, "prop", babelHelpers.classPrivateMethodGet(this, _Cl_brand, _method).call(this, 1));
babelHelpers.classPrivateFieldInitSpec(this, _priv, babelHelpers.classPrivateMethodGet(this, _Cl_brand, _method).call(this, 2));
babelHelpers.defineProperty(this, "prop", babelHelpers.assertClassBrand(this, _Cl_brand, _method).call(this, 1));
babelHelpers.classPrivateFieldInitSpec(this, _priv, babelHelpers.assertClassBrand(this, _Cl_brand, _method).call(this, 2));
}
getPriv() {
return babelHelpers.classPrivateFieldGet2(this, _priv);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ console.log((_A_brand = /*#__PURE__*/new WeakSet(), class A {
babelHelpers.classPrivateMethodInitSpec(this, _A_brand);
}
method() {
babelHelpers.classPrivateMethodGet(this, _A_brand, _foo).call(this);
babelHelpers.assertClassBrand(this, _A_brand, _foo).call(this);
}
}));
function _foo() {}
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ class Foo {
this.status = status;
}
getCurrentStatus() {
return babelHelpers.classPrivateMethodGet(this, _Foo_brand, _getStatus).call(this);
return babelHelpers.assertClassBrand(this, _Foo_brand, _getStatus).call(this);
}
setCurrentStatus(newStatus) {
this.status = newStatus;
}
getFakeStatus(fakeStatus) {
var fakeGetStatus = babelHelpers.classPrivateMethodGet(this, _Foo_brand, _getStatus);
var fakeGetStatus = babelHelpers.assertClassBrand(this, _Foo_brand, _getStatus);
return function () {
return fakeGetStatus.call({
status: fakeStatus
Expand All @@ -21,7 +21,7 @@ class Foo {
getFakeStatusFunc() {
return {
status: 'fake-status',
getFakeStatus: babelHelpers.classPrivateMethodGet(this, _Foo_brand, _getStatus)
getFakeStatus: babelHelpers.assertClassBrand(this, _Foo_brand, _getStatus)
};
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ class Foo {
constructor() {
babelHelpers.classPrivateMethodInitSpec(this, _Foo_brand);
if (exfiltrated === undefined) {
exfiltrated = babelHelpers.classPrivateMethodGet(this, _Foo_brand, _privateMethod);
exfiltrated = babelHelpers.assertClassBrand(this, _Foo_brand, _privateMethod);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ class Cl {
babelHelpers.classPrivateMethodInitSpec(this, _Cl_brand);
}
test() {
return babelHelpers.classPrivateMethodGet(this, _Cl_brand, _foo).call(this);
return babelHelpers.assertClassBrand(this, _Cl_brand, _foo).call(this);
}
}
function* _foo() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class Sub extends Base {
return 'bad';
}
publicMethod() {
return babelHelpers.classPrivateMethodGet(this, _Sub_brand, _privateMethod).call(this);
return babelHelpers.assertClassBrand(this, _Sub_brand, _privateMethod).call(this);
}
}
_Sub = Sub;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ class Foo {
}
}
function _tag() {
babelHelpers.classPrivateMethodGet(this, _Foo_brand, _tag).bind(this)``;
babelHelpers.assertClassBrand(this, _Foo_brand, _tag).bind(this)``;
}
new Foo();