perf: improve scoped slots change detection accuracy #9371
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Ensure that state mutations that only affect parent scope only trigger parent update and does not affect child components with only scoped slots.
Implications:
For optimal performance, scoped slots should always be preferred. (In v3 all slots are unified to work like scoped slots so that will be the default)
In 2.6, any slots using the new
v-slot
syntax are compiled as scopedSlots internally. This doesn't affect the child if it's using template, since<slot/>
can render both scoped and normal slots, but if the child is using render functions, it is recommended to always usethis.$scopedSlots
. It is safe to do so in 2.6 since all normal slots are proxied onthis.$scopedSlots
as well.Unfortunately, any child components with static slot content still need to be forced updated. This means the common use case of
<parent><child></child></parent>
doesn't benefit from this change, unless the default slot is explicitly forced into a scoped slot by using<parent v-slot:default><child></child></parent>
. (We cannot directly force all slots into scoped slots as that would break existing render function code that expects the slot to be present onthis.$slots
instead of `this.$scopedSlots)