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

[@vue/compat] Prevent local asset registration from affecting other local apps (fix #5699) #5979

merged 5 commits into from May 23, 2022


Copy link

Closes #5699. Because applySingletonAppMutations copies the reference of the singleton context instead of a copy of it, all local asset registration into any local app modifies all other local apps both post-facto and globally. My initial take at solving this was to simply create a shallow copy of the singleton app context instead of copying the reference, but then I realized the existing implementation allows for code like the following to work:

const app = createApp({ template: '<foo />' });
Vue.component('foo', /* some impl */);
app.mount(...); // resolves 'foo' from the global registry even though it was created after the fact

I'm not sure if this is behavior we wanted or meant to have, but in the interest of not breaking anything, I added a test for both the original issue and this one, and fixed both by using a proxy setup which first attempts to resolve components from the singletonApp registry, and if that doesn't work it instead resolves them from the local one. This implementation passes all tests. (If we're not interested in preserving the old behavior of allowing post-facto global registrations to affect local apps, then we can strip off the latter two commits and use the much simpler shallow copy implementation).

@yyx990803 yyx990803 merged commit 7fb5732 into vuejs:main May 23, 2022
9 checks passed
Copy link

I simplified to logic to still pass the test.

Note that:

Copy link
Contributor Author

oh nice. using the singleton app's context as the prototype makes for a pretty natural solution. looking forward to the release for this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
None yet

Successfully merging this pull request may close these issues.

[vue/compat] createApp copy singletonApp configs even set { mode:3 } to compatConfig
2 participants