fix: vue 2 support for provideLocal and injectLocal #3464
Merged
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.
Before submitting the PR, please make sure you do the following
fixes #123
).Description
fix vue 2.7 support for provideLocal and injectLocal
See
https://github.com/vuejs/vue/blob/49b6bd4264c25ea41408f066a1835f38bf6fe9f1/src/v3/currentInstance.ts#L5-L14
Every time call getCurrentInstance in vue 2.7 will create a new Object锛宻o we should use getCurrentInstance()?.proxy other than getCurrentInstance() as WeakMap key.
Additional context
馃 Generated by Copilot at 9bfc23c
This pull request fixes bugs and adds tests for the
provideLocal
andinjectLocal
functions, which enable local state management across components. It uses theproxy
property of the component instance to access and set the local state in thelocalProvidedStateMap
weak map.馃 Generated by Copilot at 9bfc23c
provideLocal
andinjectLocal
functions that use the wrong instance object to access and set the local state (link, link)localProvidedStateMap
variable to use theproxy
property of the instance as the key (link)provideLocal
andinjectLocal
functions usingvitest
andvue-demi
(link)