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

use symbol value as key #7157

Closed
djfos opened this issue Nov 30, 2017 · 2 comments · Fixed by #7271
Closed

use symbol value as key #7157

djfos opened this issue Nov 30, 2017 · 2 comments · Fixed by #7271

Comments

@djfos
Copy link

djfos commented Nov 30, 2017

What problem does this feature solve?

[Vue warn]: Avoid using non-primitive value as key, use string/number value instead.

symbol is primitive value and very suitable as key.

What does the proposed API look like?

no warnings with symbol

@djfos djfos changed the title using symbol value as key use symbol value as key Nov 30, 2017
@posva
Copy link
Member

posva commented Nov 30, 2017

The funny thing is the warning is technically incorrect because Symbol is a primitive type.

If we allow Symbols as keys, some people would try to use them as Symbol(aValue) and if that is done inside of a computed property, it would change every time the array changes (as Symbol always returns a new Symbol). So I think it would be worthy to also add a not on the docs.
Because after all, it's up to people to correctly use Symbols and most people will still use plain string or numbers id

@djfos djfos closed this as completed Dec 4, 2017
@posva posva reopened this Dec 4, 2017
HerringtonDarkholme added a commit to HerringtonDarkholme/vue that referenced this issue Dec 19, 2017
@ElVisPL
Copy link

ElVisPL commented Jan 14, 2020

This warning still exists on IE11

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

Successfully merging a pull request may close this issue.

3 participants