fix(runtime-core): use separate prop caches for components and mixins #11350
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.
Closes #7998.
The merging of component props in
normalizePropsOptions
uses a cache. Currently this cache doesn't take into account theasMixin
flag, which can lead to cache entries being used incorrectly.The problem scenarios occur when a component is used both directly and via
extends
/mixins
. Any props in global mixins should not be applied whenasMixin
istrue
.This PR splits the cache into two, one for when
asMixin
istrue
and one for when it isfalse
.The existing cache is stored at
appContext.propsCache
. That cache cannot be shared between applications as each application has its own global mixins. That cache is still used when normalizing props for components.I've added a new cache that is used when normalizing props for mixins. The global mixins aren't included in other mixins, so there's no need to tie the cache to the application.
Some examples:
main
main
There is an existing PR, #7998, that fixes the problem for example 1, but not for example 2. This PR includes the commit from that earlier PR. The fix is a bit different but the test case carries over.