-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(es/compat): Avoid reserved name for private method (#8949)
**Description:** Following development should follow babel/babel#16261 to avoid separate `WeakMap` for each individual private method **Related issue:** - Closes #8948.
- Loading branch information
Showing
7 changed files
with
125 additions
and
18 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
24 changes: 24 additions & 0 deletions
24
...s_compat/tests/__swc_snapshots__/tests/es2022_class_properties.rs/loose_keyword_method.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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
var _switch = /*#__PURE__*/ _class_private_field_loose_key("_switch"), _bar = /*#__PURE__*/ _class_private_field_loose_key("_bar"); | ||
class TestCls { | ||
foo() { | ||
_class_private_field_loose_base(this, _bar)[_bar](); | ||
_class_private_field_loose_base(this, _switch)[_switch](); | ||
} | ||
constructor(){ | ||
Object.defineProperty(this, _switch, { | ||
value: __switch | ||
}); | ||
Object.defineProperty(this, _bar, { | ||
value: bar | ||
}); | ||
} | ||
} | ||
function __switch() { | ||
console.log("#switch called"); | ||
} | ||
function bar() { | ||
console.log("#bar called"); | ||
} | ||
export { TestCls }; | ||
let a = new TestCls; | ||
a.foo(); |
16 changes: 16 additions & 0 deletions
16
crates/swc_ecma_transforms_compat/tests/class-properties/issue-8948/input.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 |
---|---|---|
@@ -0,0 +1,16 @@ | ||
class TestCls { | ||
foo() { | ||
this.#bar(); | ||
this.#switch(); | ||
} | ||
#switch() { | ||
console.log("#switch called"); | ||
} | ||
|
||
#bar() { | ||
console.log("#bar called"); | ||
} | ||
} | ||
|
||
let a = new TestCls(); | ||
a.foo(); |
19 changes: 19 additions & 0 deletions
19
crates/swc_ecma_transforms_compat/tests/class-properties/issue-8948/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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
var _switch = /*#__PURE__*/ new WeakSet(), _bar = /*#__PURE__*/ new WeakSet(); | ||
class TestCls { | ||
foo() { | ||
_class_private_method_get(this, _bar, bar).call(this); | ||
_class_private_method_get(this, _switch, __switch).call(this); | ||
} | ||
constructor(){ | ||
_class_private_method_init(this, _switch); | ||
_class_private_method_init(this, _bar); | ||
} | ||
} | ||
function __switch() { | ||
console.log("#switch called"); | ||
} | ||
function bar() { | ||
console.log("#bar called"); | ||
} | ||
let a = new TestCls(); | ||
a.foo(); |
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