protect against replacing a class expression with itself when attempting to infer a new function name - fixes #2803
This commit is contained in:
@@ -0,0 +1 @@
|
||||
var o = { foo: class foo {} };
|
||||
@@ -0,0 +1,3 @@
|
||||
var o = { foo: function foo() {
|
||||
babelHelpers.classCallCheck(this, foo);
|
||||
} };
|
||||
@@ -20,7 +20,7 @@ export default function ({ types: t }) {
|
||||
|
||||
ClassExpression(path, state) {
|
||||
let inferred = nameFunction(path);
|
||||
if (inferred) return path.replaceWith(inferred);
|
||||
if (inferred && inferred !== path.node) return path.replaceWith(inferred);
|
||||
|
||||
let Constructor = VanillaTransformer;
|
||||
if (state.opts.loose) Constructor = LooseTransformer;
|
||||
|
||||
Reference in New Issue
Block a user