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

Crashes with some polyfills: @@toStringTag is not writable. #320

Open
amangeot opened this issue Oct 13, 2017 · 7 comments
Open

Crashes with some polyfills: @@toStringTag is not writable. #320

amangeot opened this issue Oct 13, 2017 · 7 comments

Comments

@amangeot
Copy link

amangeot commented Oct 13, 2017

Hello,
I receive this error in console on Android Kitkat webviews:

Uncaught TypeError: Cannot assign to read only property '@@toStringTag' of [object Object]", source: http://192.168.1.23:5050/vendor.19.js

Troubles arise from this line: Gp[toStringTagSymbol] = "Generator";
because toStringTagSymbol is not writable.

Some polyfills made it writable polyfillpolyfill/polyfill-service#1295 to make sure it works with regenerator.

So I wrote about the issue here: medikoo/es6-symbol#24, but apparently the spec wants @@toStringTag to not be writable.
EDIT: I thought it was related to this polyfill I use

Is it possible to not overwrite @@toStringTag ?

@zloirock
Copy link
Contributor

You refer to Symbol.prototype[@@toStringTag], but it's absolutely unrelated this problem and Generator.prototype[@@toStringTag].

@amangeot amangeot changed the title Crashes with some polyfills: Symbol.toStringTag is not writable. Crashes with some polyfills: @@toStringTag is not writable. Oct 14, 2017
@amangeot
Copy link
Author

amangeot commented Oct 14, 2017

Oh sorry you're right! I updated the issue, I'm quite confused with these tags.

Do you have any suggestion on how to tackle this issue? Is there something to polyfill, or a polyfill to fix?

@zloirock
Copy link
Contributor

Without digging the problem, I can say only that Symbol polyfill from core-js should work as expected -)

@amangeot
Copy link
Author

amangeot commented Oct 15, 2017

Yes that should be safe!

Considering that @@toStringTag is set to writable: false for GeneratorFunction, according to this spec,

is this line ok: Gp[toStringTagSymbol] = "Generator"?


Gp is defined as is:

  var Gp = GeneratorFunctionPrototype.prototype =
    Generator.prototype = Object.create(IteratorPrototype);
  GeneratorFunction.prototype = Gp.constructor = GeneratorFunctionPrototype;
  GeneratorFunctionPrototype.constructor = GeneratorFunction;
  GeneratorFunctionPrototype[toStringTagSymbol] =
    GeneratorFunction.displayName = "GeneratorFunction";

@zloirock
Copy link
Contributor

It should be non-writable, but regenerator not so strict. var Gp = Object.create(IteratorPrototype), so the problem in %IteratorPrototype%. regenerator uses %IteratorPrototype% from your environment where it's available, so that means that you have %IteratorPrototype% with non-writable @@toStringTag. It was fixed as writable in polyfill-service, but by the spec %IteratorPrototype% should not have @@toStringTag property.

@medikoo
Copy link

medikoo commented Oct 17, 2017

Fixed in es6-iterator, new version published at v2.0.3

@ExE-Boss
Copy link
Contributor

ExE-Boss commented Jul 27, 2020

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

4 participants