-
-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
Static Slots optimization combined with component instance re-use can lead to stale slot content never being updated. [EDGE CASE] #2893
Comments
The cause is that the slots for each Not sure we can fix this at the compiler level without de-optimizing the usually justified use-cases of keeping slots stable. It can be corrected by applying a <template>
<B>
<A key="A">Hello</A>
<A key="B">World</A>
</B>
</template> You could also apply these keys to the vnodes within the render function of |
Yeah I know key will help to fix this. But I guess it's better to update this behavior because I spend 2-3 hours to find out why😂, it's really confusing when I face it. |
Well I'm saying that at least I personally don't see how, as the problem you are facing here is not detectable by static analysis during compilation. So the only way I can see would be to never optimize slots in this way, which is too high a price to solve such an edge case, in my opinion. Maybe a better route would be to document the edge cases one can come across when manually manipulating slots content in render functions. |
Yeah, if only edge case like this will face this issue, maybe a doc is enough. Can we find a way to warning when people manually manipulating slots content in render functions? |
) fix #2893 Manually rendering the optimized slots should allow subsequent updates to exit the optimization mode correctly
Version
3.0.4
Reproduction link
https://codesandbox.io/s/demo-for-sfc-slots-issue-n27kc
Steps to reproduce
You can see
Hello
never change toWorld
.I already find the reason is that SFC compiler add
{ _: 1 }
to the compiled slots, which inupdateSlots
tell Vue there is no need to updateinstance.slots
. But in this case, it work not correctly.What is expected?
Hello
andWorld
switch in 1 secondWhat is actually happening?
never update
The text was updated successfully, but these errors were encountered: