Skip to content
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

Overwrite non-subclassable promises #23

Closed
jakearchibald opened this issue Apr 28, 2014 · 5 comments
Closed

Overwrite non-subclassable promises #23

jakearchibald opened this issue Apr 28, 2014 · 5 comments
Labels

Comments

@jakearchibald
Copy link
Collaborator

Firefox/Chrome promises throw when you call constructor on a subclass. The polyfill should take over in browsers that do that.

@stefanpenner
Copy link
Owner

👍

@stefanpenner
Copy link
Owner

so currently precisely 0 browser support this. Would we like to still check and override?

@jakearchibald
Copy link
Collaborator Author

Happy to clobber all until we get an implementation that supports subclassing, then we can look at how best to feature test it.

@stefanpenner
Copy link
Owner

  • subclass-ability is now a criteria for polyfil
  • update readme accordingly

Something like the following (although it adds many bytes).

var isNative = Object.prototype.toString.call(Promise.resolve())  === '[object Promise]';

function testSubclassing() {
  function SubClass() {
    Promise.call(this);
  }

  SubClass.prototype= Object.create(Promise.prototype)

  var seemsToSubClass;
  try {
    new SubClass(function() { });
    seemsToSubClass  = true;
  } catch(e) {
    seemsToSubClass = false
  }

  return seemsToSubClass;
}



if (isNative) {
  canSubclass = testSubClassing();
}

@stefanpenner
Copy link
Owner

master should do this now, but If you have time to audit it that would be awesome.!

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

No branches or pull requests

2 participants