diff --git a/packages/babel-plugin-proposal-private-methods/test/fixtures/accessors-loose/basic/output.js b/packages/babel-plugin-proposal-private-methods/test/fixtures/accessors-loose/basic/output.js index 7cce54cfc6..d3fad762b4 100644 --- a/packages/babel-plugin-proposal-private-methods/test/fixtures/accessors-loose/basic/output.js +++ b/packages/babel-plugin-proposal-private-methods/test/fixtures/accessors-loose/basic/output.js @@ -1,10 +1,5 @@ -var Cl = -/*#__PURE__*/ -function () { - "use strict"; - - function Cl() { - babelHelpers.classCallCheck(this, Cl); +class Cl { + constructor() { Object.defineProperty(this, _privateFieldValue, { get: _get_privateFieldValue, set: _set_privateFieldValue @@ -16,19 +11,15 @@ function () { this.publicField = "not secret string"; } - babelHelpers.createClass(Cl, [{ - key: "publicGetPrivateField", - value: function publicGetPrivateField() { - return babelHelpers.classPrivateFieldLooseBase(this, _privateFieldValue)[_privateFieldValue]; - } - }, { - key: "publicSetPrivateField", - value: function publicSetPrivateField(newValue) { - babelHelpers.classPrivateFieldLooseBase(this, _privateFieldValue)[_privateFieldValue] = newValue; - } - }]); - return Cl; -}(); + publicGetPrivateField() { + return babelHelpers.classPrivateFieldLooseBase(this, _privateFieldValue)[_privateFieldValue]; + } + + publicSetPrivateField(newValue) { + babelHelpers.classPrivateFieldLooseBase(this, _privateFieldValue)[_privateFieldValue] = newValue; + } + +} var _privateField = babelHelpers.classPrivateFieldLooseKey("privateField"); diff --git a/packages/babel-plugin-proposal-private-methods/test/fixtures/accessors-loose/get-only-setter/output.js b/packages/babel-plugin-proposal-private-methods/test/fixtures/accessors-loose/get-only-setter/output.js index 633bc48628..05866e2142 100644 --- a/packages/babel-plugin-proposal-private-methods/test/fixtures/accessors-loose/get-only-setter/output.js +++ b/packages/babel-plugin-proposal-private-methods/test/fixtures/accessors-loose/get-only-setter/output.js @@ -1,16 +1,16 @@ -var Cl = function Cl() { - "use strict"; +class Cl { + constructor() { + Object.defineProperty(this, _privateFieldValue, { + set: _set_privateFieldValue + }); + Object.defineProperty(this, _privateField, { + writable: true, + value: 0 + }); + this.publicField = babelHelpers.classPrivateFieldLooseBase(this, _privateFieldValue)[_privateFieldValue]; + } - babelHelpers.classCallCheck(this, Cl); - Object.defineProperty(this, _privateFieldValue, { - set: _set_privateFieldValue - }); - Object.defineProperty(this, _privateField, { - writable: true, - value: 0 - }); - this.publicField = babelHelpers.classPrivateFieldLooseBase(this, _privateFieldValue)[_privateFieldValue]; -}; +} var _privateField = babelHelpers.classPrivateFieldLooseKey("privateField"); diff --git a/packages/babel-plugin-proposal-private-methods/test/fixtures/accessors-loose/options.json b/packages/babel-plugin-proposal-private-methods/test/fixtures/accessors-loose/options.json index 066b15ae8a..50c7612f83 100644 --- a/packages/babel-plugin-proposal-private-methods/test/fixtures/accessors-loose/options.json +++ b/packages/babel-plugin-proposal-private-methods/test/fixtures/accessors-loose/options.json @@ -8,7 +8,6 @@ ], ["proposal-private-methods", { "loose": true }], ["proposal-class-properties", { "loose": true }], - "transform-classes", "transform-block-scoping", "syntax-class-properties" ] diff --git a/packages/babel-plugin-proposal-private-methods/test/fixtures/accessors-loose/set-only-getter/output.js b/packages/babel-plugin-proposal-private-methods/test/fixtures/accessors-loose/set-only-getter/output.js index da3238ac56..57a8789016 100644 --- a/packages/babel-plugin-proposal-private-methods/test/fixtures/accessors-loose/set-only-getter/output.js +++ b/packages/babel-plugin-proposal-private-methods/test/fixtures/accessors-loose/set-only-getter/output.js @@ -1,16 +1,16 @@ -var Cl = function Cl() { - "use strict"; +class Cl { + constructor() { + Object.defineProperty(this, _privateFieldValue, { + get: _get_privateFieldValue + }); + Object.defineProperty(this, _privateField, { + writable: true, + value: 0 + }); + babelHelpers.classPrivateFieldLooseBase(this, _privateFieldValue)[_privateFieldValue] = 1; + } - babelHelpers.classCallCheck(this, Cl); - Object.defineProperty(this, _privateFieldValue, { - get: _get_privateFieldValue - }); - Object.defineProperty(this, _privateField, { - writable: true, - value: 0 - }); - babelHelpers.classPrivateFieldLooseBase(this, _privateFieldValue)[_privateFieldValue] = 1; -}; +} var _privateField = babelHelpers.classPrivateFieldLooseKey("privateField"); diff --git a/packages/babel-plugin-proposal-private-methods/test/fixtures/accessors-loose/updates/output.js b/packages/babel-plugin-proposal-private-methods/test/fixtures/accessors-loose/updates/output.js index a1151fa55e..5dadfcf269 100644 --- a/packages/babel-plugin-proposal-private-methods/test/fixtures/accessors-loose/updates/output.js +++ b/packages/babel-plugin-proposal-private-methods/test/fixtures/accessors-loose/updates/output.js @@ -1,10 +1,5 @@ -var Cl = -/*#__PURE__*/ -function () { - "use strict"; - - function Cl() { - babelHelpers.classCallCheck(this, Cl); +class Cl { + constructor() { Object.defineProperty(this, _privateFieldValue, { get: _get_privateFieldValue, set: _set_privateFieldValue @@ -16,41 +11,36 @@ function () { this.publicField = "not secret string"; } - babelHelpers.createClass(Cl, [{ - key: "publicGetPrivateField", - value: function publicGetPrivateField() { - return babelHelpers.classPrivateFieldLooseBase(this, _privateFieldValue)[_privateFieldValue]; - } - }, { - key: "publicSetPrivateField", - value: function publicSetPrivateField(newValue) { - babelHelpers.classPrivateFieldLooseBase(this, _privateFieldValue)[_privateFieldValue] = newValue; - } - }, { - key: "testUpdates", - value: function testUpdates() { - babelHelpers.classPrivateFieldLooseBase(this, _privateField)[_privateField] = 0; - this.publicField = 0; - babelHelpers.classPrivateFieldLooseBase(this, _privateFieldValue)[_privateFieldValue] = babelHelpers.classPrivateFieldLooseBase(this, _privateFieldValue)[_privateFieldValue]++; - this.publicFieldValue = this.publicFieldValue++; - ++babelHelpers.classPrivateFieldLooseBase(this, _privateFieldValue)[_privateFieldValue]; - ++this.publicFieldValue; - babelHelpers.classPrivateFieldLooseBase(this, _privateFieldValue)[_privateFieldValue] += 1; - this.publicFieldValue += 1; - babelHelpers.classPrivateFieldLooseBase(this, _privateFieldValue)[_privateFieldValue] = -(babelHelpers.classPrivateFieldLooseBase(this, _privateFieldValue)[_privateFieldValue] ** babelHelpers.classPrivateFieldLooseBase(this, _privateFieldValue)[_privateFieldValue]); - this.publicFieldValue = -(this.publicFieldValue ** this.publicFieldValue); - } - }, { - key: "publicFieldValue", - get: function () { - return this.publicField; - }, - set: function (newValue) { - this.publicField = newValue; - } - }]); - return Cl; -}(); + publicGetPrivateField() { + return babelHelpers.classPrivateFieldLooseBase(this, _privateFieldValue)[_privateFieldValue]; + } + + publicSetPrivateField(newValue) { + babelHelpers.classPrivateFieldLooseBase(this, _privateFieldValue)[_privateFieldValue] = newValue; + } + + get publicFieldValue() { + return this.publicField; + } + + set publicFieldValue(newValue) { + this.publicField = newValue; + } + + testUpdates() { + babelHelpers.classPrivateFieldLooseBase(this, _privateField)[_privateField] = 0; + this.publicField = 0; + babelHelpers.classPrivateFieldLooseBase(this, _privateFieldValue)[_privateFieldValue] = babelHelpers.classPrivateFieldLooseBase(this, _privateFieldValue)[_privateFieldValue]++; + this.publicFieldValue = this.publicFieldValue++; + ++babelHelpers.classPrivateFieldLooseBase(this, _privateFieldValue)[_privateFieldValue]; + ++this.publicFieldValue; + babelHelpers.classPrivateFieldLooseBase(this, _privateFieldValue)[_privateFieldValue] += 1; + this.publicFieldValue += 1; + babelHelpers.classPrivateFieldLooseBase(this, _privateFieldValue)[_privateFieldValue] = -(babelHelpers.classPrivateFieldLooseBase(this, _privateFieldValue)[_privateFieldValue] ** babelHelpers.classPrivateFieldLooseBase(this, _privateFieldValue)[_privateFieldValue]); + this.publicFieldValue = -(this.publicFieldValue ** this.publicFieldValue); + } + +} var _privateField = babelHelpers.classPrivateFieldLooseKey("privateField"); diff --git a/packages/babel-plugin-proposal-private-methods/test/fixtures/accessors/basic/output.js b/packages/babel-plugin-proposal-private-methods/test/fixtures/accessors/basic/output.js index 7e8c89ba0a..650c5727ed 100644 --- a/packages/babel-plugin-proposal-private-methods/test/fixtures/accessors/basic/output.js +++ b/packages/babel-plugin-proposal-private-methods/test/fixtures/accessors/basic/output.js @@ -1,11 +1,5 @@ -var Cl = -/*#__PURE__*/ -function () { - "use strict"; - - function Cl() { - babelHelpers.classCallCheck(this, Cl); - +class Cl { + constructor() { _privateFieldValue.set(this, { get: _get_privateFieldValue, set: _set_privateFieldValue @@ -19,19 +13,15 @@ function () { this.publicField = "not secret string"; } - babelHelpers.createClass(Cl, [{ - key: "publicGetPrivateField", - value: function publicGetPrivateField() { - return babelHelpers.classPrivateFieldGet(this, _privateFieldValue); - } - }, { - key: "publicSetPrivateField", - value: function publicSetPrivateField(newValue) { - babelHelpers.classPrivateFieldSet(this, _privateFieldValue, newValue); - } - }]); - return Cl; -}(); + publicGetPrivateField() { + return babelHelpers.classPrivateFieldGet(this, _privateFieldValue); + } + + publicSetPrivateField(newValue) { + babelHelpers.classPrivateFieldSet(this, _privateFieldValue, newValue); + } + +} var _privateField = new WeakMap(); diff --git a/packages/babel-plugin-proposal-private-methods/test/fixtures/accessors/get-only-setter/output.js b/packages/babel-plugin-proposal-private-methods/test/fixtures/accessors/get-only-setter/output.js index 6c3748b97b..0906668c51 100644 --- a/packages/babel-plugin-proposal-private-methods/test/fixtures/accessors/get-only-setter/output.js +++ b/packages/babel-plugin-proposal-private-methods/test/fixtures/accessors/get-only-setter/output.js @@ -1,19 +1,18 @@ -var Cl = function Cl() { - "use strict"; +class Cl { + constructor() { + _privateFieldValue.set(this, { + set: _set_privateFieldValue + }); - babelHelpers.classCallCheck(this, Cl); + _privateField.set(this, { + writable: true, + value: 0 + }); - _privateFieldValue.set(this, { - set: _set_privateFieldValue - }); + this.publicField = babelHelpers.classPrivateFieldGet(this, _privateFieldValue); + } - _privateField.set(this, { - writable: true, - value: 0 - }); - - this.publicField = babelHelpers.classPrivateFieldGet(this, _privateFieldValue); -}; +} var _privateField = new WeakMap(); diff --git a/packages/babel-plugin-proposal-private-methods/test/fixtures/accessors/options.json b/packages/babel-plugin-proposal-private-methods/test/fixtures/accessors/options.json index a2c2703464..c5e6649e4e 100644 --- a/packages/babel-plugin-proposal-private-methods/test/fixtures/accessors/options.json +++ b/packages/babel-plugin-proposal-private-methods/test/fixtures/accessors/options.json @@ -8,7 +8,6 @@ ], "proposal-private-methods", "proposal-class-properties", - "transform-classes", "transform-block-scoping", "syntax-class-properties" ] diff --git a/packages/babel-plugin-proposal-private-methods/test/fixtures/accessors/set-only-getter/output.js b/packages/babel-plugin-proposal-private-methods/test/fixtures/accessors/set-only-getter/output.js index 58b22116b5..4ea497e71a 100644 --- a/packages/babel-plugin-proposal-private-methods/test/fixtures/accessors/set-only-getter/output.js +++ b/packages/babel-plugin-proposal-private-methods/test/fixtures/accessors/set-only-getter/output.js @@ -1,19 +1,18 @@ -var Cl = function Cl() { - "use strict"; +class Cl { + constructor() { + _privateFieldValue.set(this, { + get: _get_privateFieldValue + }); - babelHelpers.classCallCheck(this, Cl); + _privateField.set(this, { + writable: true, + value: 0 + }); - _privateFieldValue.set(this, { - get: _get_privateFieldValue - }); + babelHelpers.classPrivateMethodSet(); + } - _privateField.set(this, { - writable: true, - value: 0 - }); - - babelHelpers.classPrivateMethodSet(); -}; +} var _privateField = new WeakMap(); diff --git a/packages/babel-plugin-proposal-private-methods/test/fixtures/accessors/updates/output.js b/packages/babel-plugin-proposal-private-methods/test/fixtures/accessors/updates/output.js index 1ecc87fa34..5d32aa2854 100644 --- a/packages/babel-plugin-proposal-private-methods/test/fixtures/accessors/updates/output.js +++ b/packages/babel-plugin-proposal-private-methods/test/fixtures/accessors/updates/output.js @@ -1,11 +1,5 @@ -var Cl = -/*#__PURE__*/ -function () { - "use strict"; - - function Cl() { - babelHelpers.classCallCheck(this, Cl); - +class Cl { + constructor() { _privateFieldValue.set(this, { get: _get_privateFieldValue, set: _set_privateFieldValue @@ -19,43 +13,38 @@ function () { this.publicField = "not secret string"; } - babelHelpers.createClass(Cl, [{ - key: "publicGetPrivateField", - value: function publicGetPrivateField() { - return babelHelpers.classPrivateFieldGet(this, _privateFieldValue); - } - }, { - key: "publicSetPrivateField", - value: function publicSetPrivateField(newValue) { - babelHelpers.classPrivateFieldSet(this, _privateFieldValue, newValue); - } - }, { - key: "testUpdates", - value: function testUpdates() { - var _this$privateFieldVal, _this$privateFieldVal2; + publicGetPrivateField() { + return babelHelpers.classPrivateFieldGet(this, _privateFieldValue); + } - babelHelpers.classPrivateFieldSet(this, _privateField, 0); - this.publicField = 0; - babelHelpers.classPrivateFieldSet(this, _privateFieldValue, (babelHelpers.classPrivateFieldSet(this, _privateFieldValue, (_this$privateFieldVal2 = +babelHelpers.classPrivateFieldGet(this, _privateFieldValue)) + 1), _this$privateFieldVal2)); - this.publicFieldValue = this.publicFieldValue++; - babelHelpers.classPrivateFieldSet(this, _privateFieldValue, +babelHelpers.classPrivateFieldGet(this, _privateFieldValue) + 1); - ++this.publicFieldValue; - babelHelpers.classPrivateFieldSet(this, _privateFieldValue, babelHelpers.classPrivateFieldGet(this, _privateFieldValue) + 1); - this.publicFieldValue += 1; - babelHelpers.classPrivateFieldSet(this, _privateFieldValue, -(babelHelpers.classPrivateFieldGet(this, _privateFieldValue) ** babelHelpers.classPrivateFieldGet(this, _privateFieldValue))); - this.publicFieldValue = -(this.publicFieldValue ** this.publicFieldValue); - } - }, { - key: "publicFieldValue", - get: function () { - return this.publicField; - }, - set: function (newValue) { - this.publicField = newValue; - } - }]); - return Cl; -}(); + publicSetPrivateField(newValue) { + babelHelpers.classPrivateFieldSet(this, _privateFieldValue, newValue); + } + + get publicFieldValue() { + return this.publicField; + } + + set publicFieldValue(newValue) { + this.publicField = newValue; + } + + testUpdates() { + var _this$privateFieldVal, _this$privateFieldVal2; + + babelHelpers.classPrivateFieldSet(this, _privateField, 0); + this.publicField = 0; + babelHelpers.classPrivateFieldSet(this, _privateFieldValue, (babelHelpers.classPrivateFieldSet(this, _privateFieldValue, (_this$privateFieldVal2 = +babelHelpers.classPrivateFieldGet(this, _privateFieldValue)) + 1), _this$privateFieldVal2)); + this.publicFieldValue = this.publicFieldValue++; + babelHelpers.classPrivateFieldSet(this, _privateFieldValue, +babelHelpers.classPrivateFieldGet(this, _privateFieldValue) + 1); + ++this.publicFieldValue; + babelHelpers.classPrivateFieldSet(this, _privateFieldValue, babelHelpers.classPrivateFieldGet(this, _privateFieldValue) + 1); + this.publicFieldValue += 1; + babelHelpers.classPrivateFieldSet(this, _privateFieldValue, -(babelHelpers.classPrivateFieldGet(this, _privateFieldValue) ** babelHelpers.classPrivateFieldGet(this, _privateFieldValue))); + this.publicFieldValue = -(this.publicFieldValue ** this.publicFieldValue); + } + +} var _privateField = new WeakMap(); diff --git a/packages/babel-plugin-proposal-private-methods/test/fixtures/duplicated-names/get-set/output.js b/packages/babel-plugin-proposal-private-methods/test/fixtures/duplicated-names/get-set/output.js index 0118f38b7f..baa69fd20e 100644 --- a/packages/babel-plugin-proposal-private-methods/test/fixtures/duplicated-names/get-set/output.js +++ b/packages/babel-plugin-proposal-private-methods/test/fixtures/duplicated-names/get-set/output.js @@ -1,18 +1,17 @@ -var Cl = function Cl() { - "use strict"; +class Cl { + constructor() { + _getSet.set(this, { + get: _get_getSet, + set: _set_getSet + }); - babelHelpers.classCallCheck(this, Cl); + _privateField.set(this, { + writable: true, + value: 0 + }); + } - _getSet.set(this, { - get: _get_getSet, - set: _set_getSet - }); - - _privateField.set(this, { - writable: true, - value: 0 - }); -}; +} var _privateField = new WeakMap(); diff --git a/packages/babel-plugin-proposal-private-methods/test/fixtures/duplicated-names/options.json b/packages/babel-plugin-proposal-private-methods/test/fixtures/duplicated-names/options.json index a2c2703464..c5e6649e4e 100644 --- a/packages/babel-plugin-proposal-private-methods/test/fixtures/duplicated-names/options.json +++ b/packages/babel-plugin-proposal-private-methods/test/fixtures/duplicated-names/options.json @@ -8,7 +8,6 @@ ], "proposal-private-methods", "proposal-class-properties", - "transform-classes", "transform-block-scoping", "syntax-class-properties" ] diff --git a/packages/babel-plugin-proposal-private-methods/test/fixtures/duplicated-names/set-get/output.js b/packages/babel-plugin-proposal-private-methods/test/fixtures/duplicated-names/set-get/output.js index ded950becc..305f1a49d7 100644 --- a/packages/babel-plugin-proposal-private-methods/test/fixtures/duplicated-names/set-get/output.js +++ b/packages/babel-plugin-proposal-private-methods/test/fixtures/duplicated-names/set-get/output.js @@ -1,18 +1,17 @@ -var Cl = function Cl() { - "use strict"; +class Cl { + constructor() { + _getSet.set(this, { + get: _get_getSet, + set: _set_getSet + }); - babelHelpers.classCallCheck(this, Cl); + _privateField.set(this, { + writable: true, + value: 0 + }); + } - _getSet.set(this, { - get: _get_getSet, - set: _set_getSet - }); - - _privateField.set(this, { - writable: true, - value: 0 - }); -}; +} var _privateField = new WeakMap(); diff --git a/packages/babel-plugin-proposal-private-methods/test/fixtures/private-method-loose/assignment/output.js b/packages/babel-plugin-proposal-private-methods/test/fixtures/private-method-loose/assignment/output.js index 075d1451ed..2dfef83ea5 100644 --- a/packages/babel-plugin-proposal-private-methods/test/fixtures/private-method-loose/assignment/output.js +++ b/packages/babel-plugin-proposal-private-methods/test/fixtures/private-method-loose/assignment/output.js @@ -1,12 +1,12 @@ -var Foo = function Foo() { - "use strict"; +class Foo { + constructor() { + Object.defineProperty(this, _privateMethod, { + value: _privateMethod2 + }); + this.publicField = babelHelpers.classPrivateFieldLooseBase(this, _privateMethod)[_privateMethod](); + } - babelHelpers.classCallCheck(this, Foo); - Object.defineProperty(this, _privateMethod, { - value: _privateMethod2 - }); - this.publicField = babelHelpers.classPrivateFieldLooseBase(this, _privateMethod)[_privateMethod](); -}; +} var _privateMethod = babelHelpers.classPrivateFieldLooseKey("privateMethod"); diff --git a/packages/babel-plugin-proposal-private-methods/test/fixtures/private-method-loose/before-fields/output.js b/packages/babel-plugin-proposal-private-methods/test/fixtures/private-method-loose/before-fields/output.js index 60b5075fa1..aed2cf9619 100644 --- a/packages/babel-plugin-proposal-private-methods/test/fixtures/private-method-loose/before-fields/output.js +++ b/packages/babel-plugin-proposal-private-methods/test/fixtures/private-method-loose/before-fields/output.js @@ -1,10 +1,5 @@ -var Cl = -/*#__PURE__*/ -function () { - "use strict"; - - function Cl() { - babelHelpers.classCallCheck(this, Cl); +class Cl { + constructor() { Object.defineProperty(this, _method, { value: _method2 }); @@ -15,14 +10,11 @@ function () { }); } - babelHelpers.createClass(Cl, [{ - key: "getPriv", - value: function getPriv() { - return babelHelpers.classPrivateFieldLooseBase(this, _priv)[_priv]; - } - }]); - return Cl; -}(); + getPriv() { + return babelHelpers.classPrivateFieldLooseBase(this, _priv)[_priv]; + } + +} var _priv = babelHelpers.classPrivateFieldLooseKey("priv"); diff --git a/packages/babel-plugin-proposal-private-methods/test/fixtures/private-method-loose/context/output.js b/packages/babel-plugin-proposal-private-methods/test/fixtures/private-method-loose/context/output.js index 96fb6f9073..1945a52af1 100644 --- a/packages/babel-plugin-proposal-private-methods/test/fixtures/private-method-loose/context/output.js +++ b/packages/babel-plugin-proposal-private-methods/test/fixtures/private-method-loose/context/output.js @@ -1,48 +1,37 @@ -var Foo = -/*#__PURE__*/ -function () { - "use strict"; - - function Foo(status) { - babelHelpers.classCallCheck(this, Foo); +class Foo { + constructor(status) { Object.defineProperty(this, _getStatus, { value: _getStatus2 }); this.status = status; } - babelHelpers.createClass(Foo, [{ - key: "getCurrentStatus", - value: function getCurrentStatus() { - return babelHelpers.classPrivateFieldLooseBase(this, _getStatus)[_getStatus](); - } - }, { - key: "setCurrentStatus", - value: function setCurrentStatus(newStatus) { - this.status = newStatus; - } - }, { - key: "getFakeStatus", - value: function getFakeStatus(fakeStatus) { - var fakeGetStatus = babelHelpers.classPrivateFieldLooseBase(this, _getStatus)[_getStatus]; + getCurrentStatus() { + return babelHelpers.classPrivateFieldLooseBase(this, _getStatus)[_getStatus](); + } - return function () { - return fakeGetStatus.call({ - status: fakeStatus - }); - }; - } - }, { - key: "getFakeStatusFunc", - value: function getFakeStatusFunc() { - return { - status: 'fake-status', - getFakeStatus: babelHelpers.classPrivateFieldLooseBase(this, _getStatus)[_getStatus] - }; - } - }]); - return Foo; -}(); + setCurrentStatus(newStatus) { + this.status = newStatus; + } + + getFakeStatus(fakeStatus) { + var fakeGetStatus = babelHelpers.classPrivateFieldLooseBase(this, _getStatus)[_getStatus]; + + return function () { + return fakeGetStatus.call({ + status: fakeStatus + }); + }; + } + + getFakeStatusFunc() { + return { + status: 'fake-status', + getFakeStatus: babelHelpers.classPrivateFieldLooseBase(this, _getStatus)[_getStatus] + }; + } + +} var _getStatus = babelHelpers.classPrivateFieldLooseKey("getStatus"); diff --git a/packages/babel-plugin-proposal-private-methods/test/fixtures/private-method-loose/exfiltrated/output.js b/packages/babel-plugin-proposal-private-methods/test/fixtures/private-method-loose/exfiltrated/output.js index 5ac64080fe..831162dfa6 100644 --- a/packages/babel-plugin-proposal-private-methods/test/fixtures/private-method-loose/exfiltrated/output.js +++ b/packages/babel-plugin-proposal-private-methods/test/fixtures/private-method-loose/exfiltrated/output.js @@ -1,17 +1,17 @@ var exfiltrated; -var Foo = function Foo() { - "use strict"; +class Foo { + constructor() { + Object.defineProperty(this, _privateMethod, { + value: _privateMethod2 + }); - babelHelpers.classCallCheck(this, Foo); - Object.defineProperty(this, _privateMethod, { - value: _privateMethod2 - }); - - if (exfiltrated === undefined) { - exfiltrated = babelHelpers.classPrivateFieldLooseBase(this, _privateMethod)[_privateMethod]; + if (exfiltrated === undefined) { + exfiltrated = babelHelpers.classPrivateFieldLooseBase(this, _privateMethod)[_privateMethod]; + } } -}; + +} var _privateMethod = babelHelpers.classPrivateFieldLooseKey("privateMethod"); diff --git a/packages/babel-plugin-proposal-private-methods/test/fixtures/private-method-loose/options.json b/packages/babel-plugin-proposal-private-methods/test/fixtures/private-method-loose/options.json index 066b15ae8a..50c7612f83 100644 --- a/packages/babel-plugin-proposal-private-methods/test/fixtures/private-method-loose/options.json +++ b/packages/babel-plugin-proposal-private-methods/test/fixtures/private-method-loose/options.json @@ -8,7 +8,6 @@ ], ["proposal-private-methods", { "loose": true }], ["proposal-class-properties", { "loose": true }], - "transform-classes", "transform-block-scoping", "syntax-class-properties" ] diff --git a/packages/babel-plugin-proposal-private-methods/test/fixtures/private-method/assignment/output.js b/packages/babel-plugin-proposal-private-methods/test/fixtures/private-method/assignment/output.js index 8951f902f0..2cc1c0b861 100644 --- a/packages/babel-plugin-proposal-private-methods/test/fixtures/private-method/assignment/output.js +++ b/packages/babel-plugin-proposal-private-methods/test/fixtures/private-method/assignment/output.js @@ -1,12 +1,11 @@ -var Foo = function Foo() { - "use strict"; +class Foo { + constructor() { + _privateMethod.add(this); - babelHelpers.classCallCheck(this, Foo); + this.publicField = babelHelpers.classPrivateMethodGet(this, _privateMethod, _privateMethod2).call(this); + } - _privateMethod.add(this); - - this.publicField = babelHelpers.classPrivateMethodGet(this, _privateMethod, _privateMethod2).call(this); -}; +} var _privateMethod = new WeakSet(); diff --git a/packages/babel-plugin-proposal-private-methods/test/fixtures/private-method/before-fields/output.js b/packages/babel-plugin-proposal-private-methods/test/fixtures/private-method/before-fields/output.js index 905eb09682..834c4512d0 100644 --- a/packages/babel-plugin-proposal-private-methods/test/fixtures/private-method/before-fields/output.js +++ b/packages/babel-plugin-proposal-private-methods/test/fixtures/private-method/before-fields/output.js @@ -1,11 +1,5 @@ -var Cl = -/*#__PURE__*/ -function () { - "use strict"; - - function Cl() { - babelHelpers.classCallCheck(this, Cl); - +class Cl { + constructor() { _method.add(this); babelHelpers.defineProperty(this, "prop", babelHelpers.classPrivateMethodGet(this, _method, _method2).call(this, 1)); @@ -16,14 +10,11 @@ function () { }); } - babelHelpers.createClass(Cl, [{ - key: "getPriv", - value: function getPriv() { - return babelHelpers.classPrivateFieldGet(this, _priv); - } - }]); - return Cl; -}(); + getPriv() { + return babelHelpers.classPrivateFieldGet(this, _priv); + } + +} var _priv = new WeakMap(); diff --git a/packages/babel-plugin-proposal-private-methods/test/fixtures/private-method/context/output.js b/packages/babel-plugin-proposal-private-methods/test/fixtures/private-method/context/output.js index 493abaf2be..02b0f4f726 100644 --- a/packages/babel-plugin-proposal-private-methods/test/fixtures/private-method/context/output.js +++ b/packages/babel-plugin-proposal-private-methods/test/fixtures/private-method/context/output.js @@ -1,47 +1,35 @@ -var Foo = -/*#__PURE__*/ -function () { - "use strict"; - - function Foo(status) { - babelHelpers.classCallCheck(this, Foo); - +class Foo { + constructor(status) { _getStatus.add(this); this.status = status; } - babelHelpers.createClass(Foo, [{ - key: "getCurrentStatus", - value: function getCurrentStatus() { - return babelHelpers.classPrivateMethodGet(this, _getStatus, _getStatus2).call(this); - } - }, { - key: "setCurrentStatus", - value: function setCurrentStatus(newStatus) { - this.status = newStatus; - } - }, { - key: "getFakeStatus", - value: function getFakeStatus(fakeStatus) { - var fakeGetStatus = babelHelpers.classPrivateMethodGet(this, _getStatus, _getStatus2); - return function () { - return fakeGetStatus.call({ - status: fakeStatus - }); - }; - } - }, { - key: "getFakeStatusFunc", - value: function getFakeStatusFunc() { - return { - status: 'fake-status', - getFakeStatus: babelHelpers.classPrivateMethodGet(this, _getStatus, _getStatus2) - }; - } - }]); - return Foo; -}(); + getCurrentStatus() { + return babelHelpers.classPrivateMethodGet(this, _getStatus, _getStatus2).call(this); + } + + setCurrentStatus(newStatus) { + this.status = newStatus; + } + + getFakeStatus(fakeStatus) { + var fakeGetStatus = babelHelpers.classPrivateMethodGet(this, _getStatus, _getStatus2); + return function () { + return fakeGetStatus.call({ + status: fakeStatus + }); + }; + } + + getFakeStatusFunc() { + return { + status: 'fake-status', + getFakeStatus: babelHelpers.classPrivateMethodGet(this, _getStatus, _getStatus2) + }; + } + +} var _getStatus = new WeakSet(); diff --git a/packages/babel-plugin-proposal-private-methods/test/fixtures/private-method/exfiltrated/output.js b/packages/babel-plugin-proposal-private-methods/test/fixtures/private-method/exfiltrated/output.js index 4847ebd09a..ed6b8b538e 100644 --- a/packages/babel-plugin-proposal-private-methods/test/fixtures/private-method/exfiltrated/output.js +++ b/packages/babel-plugin-proposal-private-methods/test/fixtures/private-method/exfiltrated/output.js @@ -1,16 +1,15 @@ var exfiltrated; -var Foo = function Foo() { - "use strict"; +class Foo { + constructor() { + _privateMethod.add(this); - babelHelpers.classCallCheck(this, Foo); - - _privateMethod.add(this); - - if (exfiltrated === undefined) { - exfiltrated = babelHelpers.classPrivateMethodGet(this, _privateMethod, _privateMethod2); + if (exfiltrated === undefined) { + exfiltrated = babelHelpers.classPrivateMethodGet(this, _privateMethod, _privateMethod2); + } } -}; + +} var _privateMethod = new WeakSet(); diff --git a/packages/babel-plugin-proposal-private-methods/test/fixtures/private-method/options.json b/packages/babel-plugin-proposal-private-methods/test/fixtures/private-method/options.json index a2c2703464..c5e6649e4e 100644 --- a/packages/babel-plugin-proposal-private-methods/test/fixtures/private-method/options.json +++ b/packages/babel-plugin-proposal-private-methods/test/fixtures/private-method/options.json @@ -8,7 +8,6 @@ ], "proposal-private-methods", "proposal-class-properties", - "transform-classes", "transform-block-scoping", "syntax-class-properties" ]