8000 Add a check for privateMap's existence (#11571) · babel/babel@b1923fd · GitHub
[go: up one dir, main page]

Skip to content

Commit b1923fd

Browse files
AjayPoshakAjay Poshak
andauthored
Add a check for privateMap's existence (#11571)
Co-authored-by: Ajay Poshak <ajay.poshak@bookmyshow.com>
1 parent cd9c71c commit b1923fd

File tree

117 files changed

+332
-333
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

117 files changed

+332
-333
lines changed

packages/babel-helper-create-class-features-plugin/src/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,8 +182,8 @@ export function createClassFeaturePlugin({
182182
}
183183

184184
path = wrapClass(path);
185-
path.insertBefore(keysNodes);
186-
path.insertAfter([...privateNamesNodes, ...staticNodes]);
185+
path.insertBefore([...privateNamesNodes, ...keysNodes]);
186+
path.insertAfter(staticNodes);
187187
},
188188

189189
PrivateName(path) {
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1+
var _privateMethod = new WeakSet();
2+
13
class X {
24
constructor() {
35
_privateMethod.add(this);
46
}
57

68
}
79

8-
var _privateMethod = new WeakSet();
9-
1010
var _privateMethod2 = function _privateMethod2() {
1111
return 42;
1212
};

packages/babel-helper-create-class-features-plugin/test/fixtures/plugin-proposal-private-methods/loose-true/output.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ var id = 0;
22

33
function _classPrivateFieldLooseKey(name) { return "__private_" + id++ + "_" + name; }
44

5+
var _privateMethod = _classPrivateFieldLooseKey("privateMethod");
6+
57
class X {
68
constructor() {
79
Object.defineProperty(this, _privateMethod, {
@@ -11,8 +13,6 @@ class X {
1113

1214
}
1315

14-
var _privateMethod = _classPrivateFieldLooseKey("privateMethod");
15-
1616
var _privateMethod2 = function _privateMethod2() {
1717
return 42;
1818
};

packages/babel-plugin-proposal-class-properties/test/fixtures/private-loose/assignment/output.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
var _foo = babelHelpers.classPrivateFieldLooseKey("foo");
2+
13
var Foo = /*#__PURE__*/function () {
24
"use strict";
35

@@ -20,5 +22,3 @@ var Foo = /*#__PURE__*/function () {
2022
}]);
2123
return Foo;
2224
}();
23-
24-
var _foo = babelHelpers.classPrivateFieldLooseKey("foo");

packages/babel-plugin-proposal-class-properties/test/fixtures/private-loose/call/output.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
var _foo = babelHelpers.classPrivateFieldLooseKey("foo");
2+
13
var Foo = /*#__PURE__*/function () {
24
"use strict";
35

@@ -21,5 +23,3 @@ var Foo = /*#__PURE__*/function () {
2123
}]);
2224
return Foo;
2325
}();
24-
25-
var _foo = babelHelpers.classPrivateFieldLooseKey("foo");

packages/babel-plugin-proposal-class-properties/test/fixtures/private-loose/canonical/output.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
var _x = babelHelpers.classPrivateFieldLooseKey("x");
2+
3+
var _y = babelHelpers.classPrivateFieldLooseKey("y");
4+
15
var Point = /*#__PURE__*/function () {
26
"use strict";
37

@@ -44,7 +48,3 @@ var Point = /*#__PURE__*/function () {
4448
}]);
4549
return Point;
4650
}();
47-
48-
var _x = babelHelpers.classPrivateFieldLooseKey("x");
49-
50-
var _y = babelHelpers.classPrivateFieldLooseKey("y");

packages/babel-plugin-proposal-class-properties/test/fixtures/private-loose/constructor-collision/output.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
var foo = "bar";
22

3+
var _bar = babelHelpers.classPrivateFieldLooseKey("bar");
4+
35
var Foo = function Foo() {
46
"use strict";
57

@@ -10,5 +12,3 @@ var Foo = function Foo() {
1012
});
1113
var _foo = "foo";
1214
};
13-
14-
var _bar = babelHelpers.classPrivateFieldLooseKey("bar");

packages/babel-plugin-proposal-class-properties/test/fixtures/private-loose/declaration-order/output.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
var _x = babelHelpers.classPrivateFieldLooseKey("x");
2+
13
var C = function C() {
24
"use strict";
35

@@ -9,8 +11,6 @@ var C = function C() {
911
});
1012
};
1113

12-
var _x = babelHelpers.classPrivateFieldLooseKey("x");
13-
1414
expect(() => {
1515
new C();
1616
}).toThrow();

packages/babel-plugin-proposal-class-properties/test/fixtures/private-loose/derived-multiple-supers/output.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
var _bar = babelHelpers.classPrivateFieldLooseKey("bar");
2+
13
var Foo = /*#__PURE__*/function (_Bar) {
24
"use strict";
35

@@ -29,5 +31,3 @@ var Foo = /*#__PURE__*/function (_Bar) {
2931

3032
return Foo;
3133
}(Bar);
32-
33-
var _bar = babelHelpers.classPrivateFieldLooseKey("bar");

packages/babel-plugin-proposal-class-properties/test/fixtures/private-loose/derived/output.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
var _prop = babelHelpers.classPrivateFieldLooseKey("prop");
2+
13
var Foo = function Foo() {
24
"use strict";
35

@@ -8,7 +10,7 @@ var Foo = function Foo() {
810
});
911
};
1012

11-
var _prop = babelHelpers.classPrivateFieldLooseKey("prop");
13+
var _prop2 = babelHelpers.classPrivateFieldLooseKey("prop");
1214

1315
var Bar = /*#__PURE__*/function (_Foo) {
1416
"use strict";
@@ -31,5 +33,3 @@ var Bar = /*#__PURE__*/function (_Foo) {
3133

3234
return Bar;
3335
}(Foo);
34-
35-
var _prop2 = babelHelpers.classPrivateFieldLooseKey("prop");

0 commit comments

Comments
 (0)
0