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): dimiss extended component props #7998

Closed
wants to merge 1 commit into from

Conversation

gcaaa31928
Copy link
Contributor

when we have a vue app which has global mixin with props

{ globalProp: { type: Boolean, default: true }}

and we have two components which is described below

const A = { name: 'A' }
const B = { name: 'B', extend: A }

and we render B first and A

it will let A missing globalProp because it already cache with not extended global mode when we render B

@github-actions
Copy link

Size Report

Bundles

File Size Gzip Brotli
runtime-dom.global.prod.js 86.5 kB (+8 B) 32.9 kB (+6 B) 29.7 kB (-38 B)
vue.global.prod.js 132 kB (+8 B) 49.6 kB (+6 B) 44.5 kB (+37 B)

Usages

Name Size Gzip Brotli
createApp 48 kB (+8 B) 18.9 kB (+5 B) 17.2 kB (+2 B)
createSSRApp 51.2 kB (+8 B) 20.2 kB (+6 B) 18.4 kB (+9 B)
defineCustomElement 50.3 kB (+8 B) 19.7 kB (+5 B) 17.9 kB (+19 B)
overall 61.3 kB (+8 B) 23.7 kB (+5 B) 21.6 kB (+43 B)

@gcaaa31928
Copy link
Contributor Author

@yyx990803 Could you please take a look at this pull request and let me know if there are any changes needed or if there are any issues?

@skirtles-code
Copy link
Contributor

If it helps anyone trying to review this, here's a reproduction of the original problem:

Here's the same example but using this PR:


The problem, as I understand it, is that the caching doesn't take into account the asMixin flag. The same component can be used both ways: directly and as a mixin (via extends). The cache just caches whichever occurs first.

I can think of two ways to approach fixing this:

  1. Use separate caches for mixins and components.
  2. Disable caching entirely for mixins.

I believe this PR is aiming for approach 2, but I think it misses an edge case. It successfully prevents props being added to the cache for mixins, but it doesn't prevent them being read from the cache. So you can still get the wrong props for a mixin if it is already in the cache.

I've tried to demonstrate that problem in this example:

I think this could be fixed by adding an asMixin check further up, where it tries to read the existing value from the cache.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Rejected
Development

Successfully merging this pull request may close these issues.

2 participants