Skip to content
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): use separate prop caches for components and mixins #11350

Merged
merged 4 commits into from
Jul 15, 2024

Conversation

skirtles-code
Copy link
Contributor

@skirtles-code skirtles-code commented Jul 13, 2024

Closes #7998.

The merging of component props in normalizePropsOptions uses a cache. Currently this cache doesn't take into account the asMixin 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 when asMixin is true.

This PR splits the cache into two, one for when asMixin is true and one for when it is false.

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:

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.

Copy link

Size Report

Bundles

File Size Gzip Brotli
runtime-dom.global.prod.js 89.6 kB (+24 B) 34.2 kB (+12 B) 30.9 kB (+43 B)
vue.global.prod.js 146 kB (+24 B) 53.7 kB (+9 B) 47.9 kB (+40 B)

Usages

Name Size Gzip Brotli
createApp 51.5 kB (+26 B) 20.1 kB (+10 B) 18.3 kB (+21 B)
createSSRApp 54.9 kB (+26 B) 21.5 kB (+11 B) 19.6 kB (+9 B)
defineCustomElement 53.8 kB (+26 B) 20.9 kB (+10 B) 19 kB (+41 B)
overall 65.3 kB (+26 B) 25.2 kB 22.7 kB (+6 B)

@yyx990803 yyx990803 merged commit b0aa234 into vuejs:main Jul 15, 2024
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants