Skip to content

super() call breaks when extending legacy classes #4970

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
WebReflection opened this issue Apr 11, 2018 · 2 comments
Closed

super() call breaks when extending legacy classes #4970

WebReflection opened this issue Apr 11, 2018 · 2 comments

Comments

@WebReflection
Copy link

When a legacy, empty, constructor does not explicitly return this, usually considered a redundant operation pretty much nobody wrote in ES3 to ES5.1 times, the super() call in MS Edge breaks like a charm, considering undefined a valid return value for a super() call, instead of the current context.

You can test this in Code Pen or through Edge HTML console.

function OldSchool() {}
function OldSchoolReturn() { return this; }
OldSchool.prototype.method =
OldSchoolReturn.prototype.method = function () {
  document.body.appendChild(
    document.createElement('p')
  ).textContent = this.constructor.name;
};
class Shenanigans extends OldSchool {
  constructor() {
    try { super().method(); }
    catch (o_O) { console.error(o_O); }
  }
}
class ShenanigansReturn extends OldSchoolReturn {
  constructor() {
    try { super().method(); }
    catch (o_O) { console.error(o_O); }
  }
}
new Shenanigans;
new ShenanigansReturn;

Thanks for fixing this.

@bterlson
Copy link
Contributor

I think this is #4663?

I'm not sure when that fix will make it into insider builds. Perhaps @liminzhu can comment.

@WebReflection
Copy link
Author

@bterlson yes, absolutely that one. I swear I've searched for super() and nothing came out ... but of course 'cause I've checked opened bugs only.

Glad to know it's fixed already. Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants