-
-
Notifications
You must be signed in to change notification settings - Fork 8.4k
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
fix(runtime-core):v-for ref behaves differently under prod and dev #6697 #6714
Conversation
wdyt? @yyx990803 😂 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A better / correct solution would involve reading ref.value in lines 101/102 in order to make it a template dependency in DEV as well (where the ref is only passed via it's string name and thus not being read in line 87).
@@ -61,7 +61,8 @@ export function setRef( | |||
return | |||
} | |||
const oldRef = oldRawRef && (oldRawRef as VNodeNormalizedRefAtom).r | |||
const refs = owner.refs === EMPTY_OBJ ? (owner.refs = {}) : owner.refs | |||
const refs = | |||
owner.refs === EMPTY_OBJ ? (owner.refs = reactive({})) : owner.refs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this is the right fix. "Options API" refs haven't been reactive in Vue 2 or Vue 3. The only way to get a reactive ref is through using a an actual ref()
/reactive()
object like in the reported issue.
Do you mean these two lines? Lines 101~102 |
The fix is close - the root cause is that in unmount / already array branches, we are only mutating the refs array, however the array is non-reactive when we get it from the When in dev mode or the binding ref is returned from setup(), the existing value should be retrieved from I made the small change to reflect this logic and reused the test. |
…en prod and dev (vuejs#6714) fix vuejs#6697
…en prod and dev (vuejs#6714) fix vuejs#6697
close: #6697