why not Reorder getTargetType check after proxyMap lookup in createReactiveObject #12807
Labels
🔨 p3-minor-bug
Priority 3: this fixes a bug, but is an edge case that only affects very specific usage.
scope: reactivity
Vue version
3.4.30
Link to minimal reproduction
https://codesandbox.io/p/devbox/vigilant-lamarr-45l4f9
Steps to reproduce
What is expected?
Since markRaw is used to mark toRaw(a) as a raw (non-reactive) object, b.a should return the original raw object a.
Therefore, b.a === a should return false, as b.a should not reference the same reactive proxy a.
What is actually happening?
but now b.a === a returns true
System Info
Any additional comments?
Suggestion: Reorder getTargetType check before proxyMap lookup in createReactiveObject.
While reading the Vue 3 source code, I noticed that in the createReactiveObject function, the proxyMap lookup is performed before the getTargetType check. I believe reordering these steps could improve both the logical clarity and performance in certain edge cases.
The current implementation prioritizes the proxyMap lookup, likely to optimize for the common case where the target is already reactive.
However, reordering the steps would make the function more robust and slightly more efficient for edge cases (e.g., invalid targets).
This change is backward-compatible and does not introduce any breaking changes.
I would appreciate feedback from the Vue core team on whether this change aligns with the design goals of Vue's reactivity system. If this suggestion is accepted, I would be happy to submit a pull request with the proposed changes.
The text was updated successfully, but these errors were encountered: