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

Library versions of Map and Set doesn't implement @@toStringTag #199

Closed
chicoxyzzy opened this issue May 16, 2016 · 5 comments
Closed

Library versions of Map and Set doesn't implement @@toStringTag #199

chicoxyzzy opened this issue May 16, 2016 · 5 comments
Labels

Comments

@chicoxyzzy
Copy link
Contributor

(new Map()).toString();
(new Set()).toString();

expected output:

[object Map]
[object Set]

actual output:

[object Object]
[object Object]

I've found this working on facebook/react#6780 (facebook/react#6780 (comment))

@zloirock
Copy link
Owner

zloirock commented May 16, 2016

Not exactly. @@toStringTag here available, but @@toStringTag behavior in Object#toString implemented only in global polyfill mode - we should not override built-ins in library version. I see only 2 possible solutions - override Object#toString in library version too or add own toString methods to Map, Set and other polyfilled built-in prototypes. Any ideas?

@chicoxyzzy
Copy link
Contributor Author

What do you mean by own toString methods?

@zloirock
Copy link
Owner

I mean toString methods with @@toStringTag logic on Map, Set, etc prototypes in library version instead of patching Object#toString.

@chicoxyzzy
Copy link
Contributor Author

chicoxyzzy commented May 19, 2016

In that case I think this is preferable and sufficient solution

@zloirock zloirock changed the title Map and Set doesn't implement @@toStringTag Library versions of Map and Set doesn't implement @@toStringTag Aug 25, 2017
@zloirock
Copy link
Owner

In v3 branch, they have own toString methods.

@zloirock zloirock mentioned this issue Mar 22, 2018
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