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(compat): ensure proper handling of render function from SFC using Vue.extend (fix: #7766) #7781

Merged
merged 1 commit into from
May 31, 2024

Conversation

LinusBorg
Copy link
Member

@LinusBorg LinusBorg commented Feb 23, 2023

This only affects compat mode

When a SFC uses Vue.extend() to define the component script, the compiler adds the render function as a property on the constructor, not the options object in .options

The same goes for internal properties added by the SFC compiler like __hmrId.

So when we create a vnode for such a component in compat mode, we have to re-assign these properties to the options object, which we then consequently use to create the actual component from.

If we don't do that, we get a template or render function missingerror.

fix: #7766

@LinusBorg LinusBorg changed the title fix(compat): ensure proper handling of render fuction from SFC using Vue.extend (fix: #7766) fix(compat): ensure proper handling of render function from SFC using Vue.extend (fix: #7766) Feb 23, 2023
@LinusBorg LinusBorg added 🔨 p3-minor-bug Priority 3: this fixes a bug, but is an edge case that only affects very specific usage. 🔍 review needed scope: v2 compat labels Feb 23, 2023
@ur92
Copy link

ur92 commented Apr 3, 2023

Thank for this fix, can you proceed to merge it?
We have a large Vue2/TS application that we want to migrate but currently we're stuck.
Thanks

@niksy
Copy link

niksy commented May 26, 2023

Does this work on subcomponent extends? For example, I have component extended with Vue.extend, and another one which extends that component (Parent.extend). I’m still getting this warning after applying these changes. This worked in Vue 2.

@sxzz sxzz added ready for review This PR requires more reviews and removed 🔍 review needed labels Aug 31, 2023
@yyx990803 yyx990803 merged commit c73847f into main May 31, 2024
@yyx990803 yyx990803 deleted the linusborg/compat-vue-extend-renderfn-7766 branch May 31, 2024 15:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🔨 p3-minor-bug Priority 3: this fixes a bug, but is an edge case that only affects very specific usage. ready for review This PR requires more reviews scope: v2 compat
Projects
Development

Successfully merging this pull request may close these issues.

@vue/compat not working with Typescript (missing template or render function)
5 participants