Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: preserve this for
super.*
template tags (#15043)
- Loading branch information
1 parent
0b0f083
commit 34ae281
Showing
5 changed files
with
86 additions
and
0 deletions.
There are no files selected for viewing
13 changes: 13 additions & 0 deletions
13
.../babel-preset-env/test/fixtures/plugins-integration/class-arrow-super-tagged-expr/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,13 @@ | ||
async function test() { | ||
class Foo { foo() { return this } } | ||
class Bar extends Foo { | ||
a = async () => super.foo`` | ||
b = async () => super['foo']`` | ||
c = async (foo) => super[foo]`` | ||
} | ||
const bar = new Bar | ||
expect(await bar.a()).toEqual(bar); | ||
expect(await bar.b()).toEqual(bar); | ||
expect(await bar.c('foo')).toEqual(bar); | ||
} | ||
test() |
16 changes: 16 additions & 0 deletions
16
...babel-preset-env/test/fixtures/plugins-integration/class-arrow-super-tagged-expr/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 @@ | ||
// This should print "true true true" | ||
async function test() { | ||
class Foo { foo() { return this } } | ||
class Bar extends Foo { | ||
a = async () => super.foo`` | ||
b = async () => super['foo']`` | ||
c = async (foo) => super[foo]`` | ||
} | ||
const bar = new Bar | ||
console.log( | ||
(await bar.a()) === bar, | ||
(await bar.b()) === bar, | ||
(await bar.c('foo')) === bar, | ||
) | ||
} | ||
test() |
4 changes: 4 additions & 0 deletions
4
...l-preset-env/test/fixtures/plugins-integration/class-arrow-super-tagged-expr/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,4 @@ | ||
{ | ||
"targets": "chrome 50", | ||
"presets": ["env"] | ||
} |
40 changes: 40 additions & 0 deletions
40
...abel-preset-env/test/fixtures/plugins-integration/class-arrow-super-tagged-expr/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,40 @@ | ||
// This should print "true true true" | ||
function test() { | ||
return _test.apply(this, arguments); | ||
} | ||
function _test() { | ||
_test = babelHelpers.asyncToGenerator(function* () { | ||
class Foo { | ||
foo() { | ||
return this; | ||
} | ||
} | ||
class Bar extends Foo { | ||
constructor(...args) { | ||
var _superprop_getFoo = () => super.foo, | ||
_this, | ||
_superprop_get = _prop => super[_prop]; | ||
super(...args); | ||
_this = this; | ||
babelHelpers.defineProperty(this, "a", /*#__PURE__*/babelHelpers.asyncToGenerator(function* () { | ||
return _superprop_getFoo().bind(_this)``; | ||
})); | ||
babelHelpers.defineProperty(this, "b", /*#__PURE__*/babelHelpers.asyncToGenerator(function* () { | ||
return _superprop_get('foo').bind(_this)``; | ||
})); | ||
babelHelpers.defineProperty(this, "c", /*#__PURE__*/function () { | ||
var _ref3 = babelHelpers.asyncToGenerator(function* (foo) { | ||
return _superprop_get(foo).bind(_this)``; | ||
}); | ||
return function (_x) { | ||
return _ref3.apply(this, arguments); | ||
}; | ||
}()); | ||
} | ||
} | ||
const bar = new Bar(); | ||
console.log((yield bar.a()) === bar, (yield bar.b()) === bar, (yield bar.c('foo')) === bar); | ||
}); | ||
return _test.apply(this, arguments); | ||
} | ||
test(); |
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