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

Use render instead of createApp when rendering vdom #181

Closed
wants to merge 1 commit into from

Conversation

larrifax
Copy link

@larrifax larrifax commented Jul 5, 2022

When rendering Vue components inside of <template #eventContent></template>, the Vue components aren't rendered within the main Vue application's context, but in a new Vue application created by the following function:

function initVue(initialContent: VNode[], parent: Vue) {
return new Vue({
parent,
data: {
content: initialContent,
},
render(h) {
let { content } = this
// the slot result can be an array, but the returned value of a vue component's
// render method must be a single node.
if (content.length === 1) {
return content[0]
} else {
return h('span', {}, content)
}
}
})
}

Since the new Vue application isn't connected to the main Vue application in any way, information about e.g. plugins are lost, making it impossible to use e.g. vue-i18n-next within the rendered components.

I've found a way to overcome this limitation, by patching the library to use render() instead of createApp(), but I'm by no means a Vue expert so I don't know if this is a viable approach or not.

The work is inspired by vuejs/core#2097 (comment) and some of the other comments in the same thread.

@acerix acerix changed the title feat: use render instead of createApp when rendering vdom Use render instead of createApp when rendering vdom Jul 5, 2022
@acerix
Copy link
Member

acerix commented Jul 5, 2022

Please submit the feature request under Issues, then link this PR to it.

@TheNoim
Copy link

TheNoim commented Aug 26, 2022

Thanks, this is a big performance issue for me.

@keygun-development
Copy link

keygun-development commented Nov 21, 2022

This is also a big performance issue for me, I've just created an issue for this.

@sebastienfontaine
Copy link

Please, this is also a big performance issue for me.

@arshaw
Copy link
Member

arshaw commented Dec 2, 2022

I've recently fixed this performance issue, though via a different technique. I'm using Teleport instead.

See my comment:
#191 (comment)

@larrifax , thank you for the effort you put into this

@arshaw arshaw closed this Dec 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants