forked from babel/babel
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix class private properties when
privateFieldsAsSymbols
(babel#16312)
* fix * remove symbol pure * add test
- Loading branch information
1 parent
0391ac2
commit 8c3b483
Showing
45 changed files
with
219 additions
and
133 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
...rm-private-methods/test/fixtures/accessors-privateFieldsAsSymbols/class-binding/output.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 4 additions & 4 deletions
8
...-private-methods/test/fixtures/accessors-privateFieldsAsSymbols/get-only-setter/output.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
...rivate-methods/test/fixtures/accessors-privateFieldsAsSymbols/preserve-comments/output.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 5 additions & 5 deletions
10
...-private-methods/test/fixtures/accessors-privateFieldsAsSymbols/set-only-getter/output.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 5 additions & 5 deletions
10
...-private-methods/test/fixtures/private-method-privateFieldsAsSymbols/assignment/output.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
var _Foo_brand = /*#__PURE__*/Symbol("privateMethod"); | ||
var _privateMethod = Symbol("privateMethod"); | ||
class Foo { | ||
constructor() { | ||
Object.defineProperty(this, _Foo_brand, { | ||
value: _privateMethod | ||
Object.defineProperty(this, _privateMethod, { | ||
value: _privateMethod2 | ||
}); | ||
this.publicField = babelHelpers.classPrivateFieldLooseBase(this, _Foo_brand)[_Foo_brand](); | ||
this.publicField = babelHelpers.classPrivateFieldLooseBase(this, _privateMethod)[_privateMethod](); | ||
} | ||
} | ||
function _privateMethod() { | ||
function _privateMethod2() { | ||
return 42; | ||
} |
14 changes: 7 additions & 7 deletions
14
...ivate-methods/test/fixtures/private-method-privateFieldsAsSymbols/before-fields/output.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,20 @@ | ||
var _priv = /*#__PURE__*/Symbol("priv"); | ||
var _Cl_brand = /*#__PURE__*/Symbol("method"); | ||
var _priv = Symbol("priv"); | ||
var _method = Symbol("method"); | ||
class Cl { | ||
constructor() { | ||
Object.defineProperty(this, _Cl_brand, { | ||
value: _method | ||
Object.defineProperty(this, _method, { | ||
value: _method2 | ||
}); | ||
babelHelpers.defineProperty(this, "prop", babelHelpers.classPrivateFieldLooseBase(this, _Cl_brand)[_Cl_brand](1)); | ||
babelHelpers.defineProperty(this, "prop", babelHelpers.classPrivateFieldLooseBase(this, _method)[_method](1)); | ||
Object.defineProperty(this, _priv, { | ||
writable: true, | ||
value: babelHelpers.classPrivateFieldLooseBase(this, _Cl_brand)[_Cl_brand](2) | ||
value: babelHelpers.classPrivateFieldLooseBase(this, _method)[_method](2) | ||
}); | ||
} | ||
getPriv() { | ||
return babelHelpers.classPrivateFieldLooseBase(this, _priv)[_priv]; | ||
} | ||
} | ||
function _method(x) { | ||
function _method2(x) { | ||
return x; | ||
} |
8 changes: 4 additions & 4 deletions
8
...ivate-methods/test/fixtures/private-method-privateFieldsAsSymbols/class-binding/output.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
var _A; | ||
var _A_brand = /*#__PURE__*/Symbol("getA"); | ||
var _getA = Symbol("getA"); | ||
class A { | ||
constructor() { | ||
Object.defineProperty(this, _A_brand, { | ||
value: _getA | ||
Object.defineProperty(this, _getA, { | ||
value: _getA2 | ||
}); | ||
} | ||
} | ||
_A = A; | ||
function _getA() { | ||
function _getA2() { | ||
return _A; | ||
} |
Oops, something went wrong.