-
-
Notifications
You must be signed in to change notification settings - Fork 8.2k
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
[@vue/reactivity] Map and Set lookups behave differently after being proxied #799
Labels
🐞 bug
Something isn't working
Comments
Related code: The cause of this bug is that we assume that the raw Map / Set contains no proxies, and instead only contains raww values. So we probably have to check for both the original raw value as well as the reactive proxy, and likely do this in more places than the function linked above. One caveat that this would have to cover / work around it that we could have both the original and proxy object in the Set/Map: const value = x: 0}
const wrappedValue = VueReactivity.reactive({value);
const set = new Set();
set.add(value)
set.add(wrappedValue) // should this warn that the original is already in the set or something?
const wrappedSet = VueReactivity.reactive(set);
wrappedSet.delete(wrappedValue) // which of the two should this delete? |
yyx990803
added a commit
that referenced
this issue
Mar 6, 2020
…ue contains reactive entries fix #799
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Version
3.0.0-alpha.7
Reproduction link
https://jsfiddle.net/k571vhbu/1/
Steps to reproduce
Insert some reactive() values into a non-reactive Set or Map. Wrap the Set or Map in reactive(). The inserted values will no longer match as keys, making get(), has(), and delete() return undefined & false.
What is expected?
After being wrapped in a reactive() proxy, the observable behaviour of a Set or Map remains unchanged.
What is actually happening?
Wrapped Sets and Maps behave differently, as described.
This behavioural bug is a result of the proxy code in @vue/reactivity unwrapping proxied keys before passing them to the underlying Map and Set methods, even if the keys already present are proxied (because they were inserted into the raw Map/Set).
The text was updated successfully, but these errors were encountered: