Skip to content

Commit

Permalink
fix super ref in computed key
Browse files Browse the repository at this point in the history
  • Loading branch information
Zzzen committed Jan 10, 2021
1 parent dbcbb3b commit 79395d9
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 5 deletions.
8 changes: 3 additions & 5 deletions packages/babel-helper-replace-supers/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,9 @@ const unshadowSuperBindingVisitor = traverse.visitors.merge([
environmentVisitor,
{
Scopable(path, { refName }) {
if (path.type === "ClassDeclaration" || path.type === "ClassExpression") {
path.skip();
return;
}
if (path.scope.hasOwnBinding(refName)) {
// https://github.com/Zzzen/babel/pull/1#pullrequestreview-564833183
const binding = path.scope.getOwnBinding(refName);
if (binding && binding.identifier.name === refName) {
path.scope.rename(refName);
}
},
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
class Foo extends Bar {
constructor() {
super();
class X {
[(() => {
let Foo;
super.method();
})()]() {}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
var Foo = /*#__PURE__*/function (_Bar) {
"use strict";

babelHelpers.inherits(Foo, _Bar);

var _super = babelHelpers.createSuper(Foo);

function Foo() {
var _thisSuper, _this;

babelHelpers.classCallCheck(this, Foo);
_this = _super.call(this);

var X = /*#__PURE__*/function () {
function X() {
babelHelpers.classCallCheck(this, X);
}

babelHelpers.createClass(X, [{
key: (() => {
var _Foo;

babelHelpers.get((_thisSuper = babelHelpers.assertThisInitialized(_this), babelHelpers.getPrototypeOf(Foo.prototype)), "method", _thisSuper).call(_thisSuper);
})(),
value: function value() {}
}]);
return X;
}();

return _this;
}

return Foo;
}(Bar);

0 comments on commit 79395d9

Please sign in to comment.