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 evaluation order of decorators with cached receiver (babel#16281)
* Add failing test * Fix evaluation order of decorators with cached receiver * Use one temp var per decorated element * Use one temp var per class
- Loading branch information
1 parent
47a20ce
commit 9194337
Showing
18 changed files
with
111 additions
and
91 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
8 changes: 3 additions & 5 deletions
8
...in-proposal-decorators/test/fixtures/2023-05-misc--to-es2015/super-in-decorator/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
13 changes: 4 additions & 9 deletions
13
...ges/babel-plugin-proposal-decorators/test/fixtures/2023-05-misc--to-es2015/this/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: 3 additions & 5 deletions
8
...posal-decorators/test/fixtures/2023-05-misc--to-es2015/valid-expression-formats/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: 3 additions & 5 deletions
8
.../babel-plugin-proposal-decorators/test/fixtures/2023-05-misc/super-in-decorator/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
13 changes: 4 additions & 9 deletions
13
packages/babel-plugin-proposal-decorators/test/fixtures/2023-05-misc/this/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
8 changes: 3 additions & 5 deletions
8
...in-proposal-decorators/test/fixtures/2023-11-misc--to-es2015/super-in-decorator/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
13 changes: 4 additions & 9 deletions
13
...ges/babel-plugin-proposal-decorators/test/fixtures/2023-11-misc--to-es2015/this/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: 3 additions & 5 deletions
8
...posal-decorators/test/fixtures/2023-11-misc--to-es2015/valid-expression-formats/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: 3 additions & 5 deletions
8
.../babel-plugin-proposal-decorators/test/fixtures/2023-11-misc/super-in-decorator/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
15 changes: 4 additions & 11 deletions
15
packages/babel-plugin-proposal-decorators/test/fixtures/2023-11-misc/this/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
17 changes: 17 additions & 0 deletions
17
...test/fixtures/2023-11-ordering--to-es2015/decorators-evaluation-with-this-caching/exec.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,17 @@ | ||
let result = []; | ||
const fn = () => { result.push(1); return () => {} } | ||
const obj = { | ||
get prop() { | ||
result.push(2); | ||
return { | ||
get foo() { result.push(3); return () => {} } | ||
} | ||
} | ||
}; | ||
class A { | ||
@fn() | ||
@obj.prop.foo | ||
method() {} | ||
} | ||
|
||
expect(result).toEqual([1, 2, 3]); |
7 changes: 7 additions & 0 deletions
7
...est/fixtures/2023-11-ordering--to-es2015/decorators-evaluation-with-this-caching/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,7 @@ | ||
let fn, obj; | ||
class A { | ||
@fn() | ||
@obj.prop.foo | ||
method() {} | ||
} | ||
|
11 changes: 11 additions & 0 deletions
11
...st/fixtures/2023-11-ordering--to-es2015/decorators-evaluation-with-this-caching/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,11 @@ | ||
var _initProto, _obj, _methodDecs, _A; | ||
let fn, obj; | ||
_methodDecs = [void 0, fn(), _obj = obj.prop, _obj.foo]; | ||
class A { | ||
constructor() { | ||
_initProto(this); | ||
} | ||
method() {} | ||
} | ||
_A = A; | ||
[_initProto] = babelHelpers.applyDecs2311(_A, [[_methodDecs, 18, "method"]], []).e; |
7 changes: 7 additions & 0 deletions
7
...ecorators/test/fixtures/2023-11-ordering/decorators-evaluation-with-this-caching/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,7 @@ | ||
let fn, obj; | ||
class A { | ||
@fn() | ||
@obj.prop.foo | ||
method() {} | ||
} | ||
|
12 changes: 12 additions & 0 deletions
12
...corators/test/fixtures/2023-11-ordering/decorators-evaluation-with-this-caching/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,12 @@ | ||
var _initProto, _obj, _methodDecs; | ||
let fn, obj; | ||
_methodDecs = [void 0, fn(), _obj = obj.prop, _obj.foo]; | ||
class A { | ||
static { | ||
[_initProto] = babelHelpers.applyDecs2311(this, [[_methodDecs, 18, "method"]], []).e; | ||
} | ||
constructor() { | ||
_initProto(this); | ||
} | ||
method() {} | ||
} |