Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: tagged template incorrect receiver (#13395)
* fix: tagged template incorrect receiver * review changes * func exp instead of arrow * review comments * update tests output * swap arrow funcs to regular funcs Co-authored-by: sagiv.bengiat <sagiv.bengiat@appsflyer.com>
- Loading branch information
Showing
20 changed files
with
229 additions
and
2 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
9 changes: 9 additions & 0 deletions
9
...bel-plugin-proposal-class-properties/test/fixtures/private/tagged-template-static/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,9 @@ | ||
class Foo { | ||
static #tag = function () { return this }; | ||
|
||
static getReceiver() { | ||
return this.#tag``; | ||
} | ||
} | ||
|
||
expect(Foo.getReceiver()).toBe(Foo); |
8 changes: 8 additions & 0 deletions
8
...el-plugin-proposal-class-properties/test/fixtures/private/tagged-template-static/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,8 @@ | ||
class Foo { | ||
static #tag = function () { return this }; | ||
|
||
static getReceiver() { | ||
return this.#tag``; | ||
} | ||
} | ||
|
6 changes: 6 additions & 0 deletions
6
...lugin-proposal-class-properties/test/fixtures/private/tagged-template-static/options.json
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,6 @@ | ||
{ | ||
"plugins": [ | ||
"proposal-class-properties", | ||
"proposal-private-methods" | ||
] | ||
} |
13 changes: 13 additions & 0 deletions
13
...l-plugin-proposal-class-properties/test/fixtures/private/tagged-template-static/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,13 @@ | ||
class Foo { | ||
static getReceiver() { | ||
return babelHelpers.classStaticPrivateFieldSpecGet(this, Foo, _tag).bind(this)``; | ||
} | ||
|
||
} | ||
|
||
var _tag = { | ||
writable: true, | ||
value: function () { | ||
return this; | ||
} | ||
}; |
17 changes: 17 additions & 0 deletions
17
...ages/babel-plugin-proposal-class-properties/test/fixtures/private/tagged-template/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 @@ | ||
class Foo { | ||
#tag() { | ||
return this; | ||
} | ||
|
||
#tag2 = function() { return this; }; | ||
|
||
constructor() { | ||
const receiver = this.#tag`tagged template`; | ||
expect(receiver).toBe(this); | ||
|
||
const receiver2 = this.#tag2`tagged template`; | ||
expect(receiver2).toBe(this); | ||
} | ||
} | ||
|
||
new Foo(); |
9 changes: 9 additions & 0 deletions
9
...ges/babel-plugin-proposal-class-properties/test/fixtures/private/tagged-template/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,9 @@ | ||
class Foo { | ||
#tag; | ||
|
||
test() { | ||
this.#tag``; | ||
} | ||
} | ||
|
||
new Foo(); |
13 changes: 13 additions & 0 deletions
13
...babel-plugin-proposal-class-properties/test/fixtures/private/tagged-template/options.json
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,13 @@ | ||
{ | ||
"presets": [ | ||
[ | ||
"@babel/preset-env", | ||
{ | ||
"shippedProposals": true, | ||
"targets": { | ||
"chrome": "75" | ||
} | ||
} | ||
] | ||
] | ||
} |
24 changes: 24 additions & 0 deletions
24
...es/babel-plugin-proposal-class-properties/test/fixtures/private/tagged-template/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,24 @@ | ||
var _tag = /*#__PURE__*/new WeakMap(); | ||
|
||
var Foo = /*#__PURE__*/function () { | ||
"use strict"; | ||
|
||
function Foo() { | ||
babelHelpers.classCallCheck(this, Foo); | ||
|
||
_tag.set(this, { | ||
writable: true, | ||
value: void 0 | ||
}); | ||
} | ||
|
||
babelHelpers.createClass(Foo, [{ | ||
key: "test", | ||
value: function test() { | ||
babelHelpers.classPrivateFieldGet(this, _tag).bind(this)``; | ||
} | ||
}]); | ||
return Foo; | ||
}(); | ||
|
||
new Foo(); |
10 changes: 10 additions & 0 deletions
10
...ges/babel-plugin-proposal-private-methods/test/fixtures/accessors/tagged-template/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,10 @@ | ||
class Foo { | ||
get #tag() { | ||
return function() { return this; }; | ||
} | ||
|
||
constructor() { | ||
const receiver = this.#tag``; | ||
expect(receiver).toBe(this); | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
...es/babel-plugin-proposal-private-methods/test/fixtures/accessors/tagged-template/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,11 @@ | ||
class Foo { | ||
get #tag() { | ||
return () => this; | ||
} | ||
|
||
constructor() { | ||
this.#tag``; | ||
} | ||
} | ||
|
||
new Foo(); |
19 changes: 19 additions & 0 deletions
19
...s/babel-plugin-proposal-private-methods/test/fixtures/accessors/tagged-template/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 _tag = /*#__PURE__*/new WeakMap(); | ||
|
||
class Foo { | ||
constructor() { | ||
_tag.set(this, { | ||
get: _get_tag, | ||
set: void 0 | ||
}); | ||
|
||
babelHelpers.classPrivateFieldGet(this, _tag).bind(this)``; | ||
} | ||
|
||
} | ||
|
||
function _get_tag() { | ||
return () => this; | ||
} | ||
|
||
new Foo(); |
11 changes: 11 additions & 0 deletions
11
...abel-plugin-proposal-private-methods/test/fixtures/private-method/tagged-template/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,11 @@ | ||
class Foo { | ||
#tag() { | ||
return this; | ||
} | ||
|
||
constructor() { | ||
const receiver = this.#tag`tagged template`; | ||
expect(receiver).toBe(this); | ||
} | ||
} | ||
new Foo(); |
6 changes: 6 additions & 0 deletions
6
...bel-plugin-proposal-private-methods/test/fixtures/private-method/tagged-template/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,6 @@ | ||
class Foo { | ||
#tag() { | ||
this.#tag``; | ||
} | ||
} | ||
new Foo(); |
14 changes: 14 additions & 0 deletions
14
...el-plugin-proposal-private-methods/test/fixtures/private-method/tagged-template/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,14 @@ | ||
var _tag = /*#__PURE__*/new WeakSet(); | ||
|
||
class Foo { | ||
constructor() { | ||
_tag.add(this); | ||
} | ||
|
||
} | ||
|
||
function _tag2() { | ||
babelHelpers.classPrivateMethodGet(this, _tag, _tag2).bind(this)``; | ||
} | ||
|
||
new Foo(); |
11 changes: 11 additions & 0 deletions
11
...ugin-proposal-private-methods/test/fixtures/private-static-method/tagged-template/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,11 @@ | ||
class Foo { | ||
static #tag() { | ||
return this; | ||
} | ||
|
||
static getReceiver() { | ||
return this.#tag``; | ||
} | ||
} | ||
|
||
expect(Foo.getReceiver()).toBe(Foo); |
6 changes: 6 additions & 0 deletions
6
...gin-proposal-private-methods/test/fixtures/private-static-method/tagged-template/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,6 @@ | ||
class Foo { | ||
static #tag() { | ||
this.#tag``; | ||
} | ||
} | ||
new Foo(); |
7 changes: 7 additions & 0 deletions
7
...in-proposal-private-methods/test/fixtures/private-static-method/tagged-template/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,7 @@ | ||
class Foo {} | ||
|
||
function _tag() { | ||
babelHelpers.classStaticPrivateMethodGet(this, Foo, _tag).bind(this)``; | ||
} | ||
|
||
new Foo(); |
10 changes: 10 additions & 0 deletions
10
...l-plugin-proposal-private-methods/test/fixtures/static-accessors/tagged-template/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,10 @@ | ||
class Foo { | ||
static get #tag() { | ||
return function() { return this; }; | ||
} | ||
|
||
static test() { | ||
const receiver = this.#tag``; | ||
expect(receiver).toBe(this); | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
...-plugin-proposal-private-methods/test/fixtures/static-accessors/tagged-template/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,18 @@ | ||
class Foo { | ||
static test() { | ||
var receiver = babelHelpers.classStaticPrivateFieldSpecGet(this, Foo, _tag).bind(this)``; | ||
expect(receiver).toBe(this); | ||
} | ||
|
||
} | ||
|
||
function _get_tag() { | ||
return function () { | ||
return this; | ||
}; | ||
} | ||
|
||
var _tag = { | ||
get: _get_tag, | ||
set: void 0 | ||
}; |