You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
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:
constvalue=x: 0}constwrappedValue=VueReactivity.reactive({value);constset=newSet();set.add(value)set.add(wrappedValue)// should this warn that the original is already in the set or something?constwrappedSet=VueReactivity.reactive(set);wrappedSet.delete(wrappedValue)// which of the two should this delete?
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: