* Don't insert `__self: this` prior to `super()` calls (#13550) `__self: this` is inserted for debugging purposes. However, it will cause a runtime error if it is inserted prior to a `super()` call in a constructor. This commit will prevent `__self: this` from inserted when there is a following `super()` call. * Prevent adding `__self` within a constructor that has `super()` altogether. * Fix 2 typos in the comments. * Add an additional test case for constructors that do not have a `super()` call. * Detect `super()` call by testing whether the class has a superclass. * Update method name and corresponding comments * Add an additional test for the case where the derived class do not have a `super()` call. * Apply the same changes to babel-plugin-transform-react-jsx
66 lines
761 B
JavaScript
66 lines
761 B
JavaScript
class A {}
|
|
|
|
class B extends A {
|
|
constructor() {
|
|
<sometag1 />;
|
|
super(<sometag2 />);
|
|
<sometag3 />;
|
|
}
|
|
|
|
}
|
|
|
|
class C {
|
|
constructor() {
|
|
<sometag4 __self={this} />;
|
|
|
|
class D extends A {
|
|
constructor() {
|
|
super();
|
|
}
|
|
|
|
}
|
|
|
|
const E = class extends A {
|
|
constructor() {
|
|
super();
|
|
}
|
|
|
|
};
|
|
}
|
|
|
|
}
|
|
|
|
class E extends A {
|
|
constructor() {
|
|
this.x = () => <sometag5 />;
|
|
|
|
this.y = function () {
|
|
return <sometag6 __self={this} />;
|
|
};
|
|
|
|
function z() {
|
|
return <sometag7 __self={this} />;
|
|
}
|
|
|
|
{
|
|
<sometag8 />;
|
|
}
|
|
super();
|
|
}
|
|
|
|
}
|
|
|
|
class F {
|
|
constructor() {
|
|
<sometag9 __self={this} />;
|
|
}
|
|
|
|
}
|
|
|
|
class G extends A {
|
|
constructor() {
|
|
return <sometag10 />;
|
|
}
|
|
|
|
}
|