[@vue/compat] Prevent local asset registration from affecting other local apps (fix #5699) #5979
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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: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).