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(runtime-core): prevent self-injection (#2400) #2424

Merged
merged 1 commit into from
Oct 20, 2020

Conversation

69hunter
Copy link
Contributor

@69hunter 69hunter commented Oct 19, 2020

fix #2400

This fix makes sure the injection in the component comes from the parent.
For the root component, it is possible to inject properties provided through plugins.

@yyx990803 yyx990803 merged commit 111d04f into vuejs:master Oct 20, 2020
@logaretm
Copy link

That would be a breaking change for some, wouldn't it? I did depend on this behavior in some cases.

@69hunter
Copy link
Contributor Author

Hi @logaretm, this fix is to align the behavior of provide/inject in composition API with options API (which is the same in Vue 2)

@logaretm
Copy link

logaretm commented Oct 21, 2020

@69hunter I understand, no worries. I just always viewed this as a feature especially I would imagine provide/inject would be used primarily with the composition API. I wasn't aware it caused issues with the options API or assumed that's expected.

I patched my code to use self-injections with getCurrentInstance at the moment, not sure if this would be confusing for users or not.

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

Successfully merging this pull request may close these issues.

provide() overrides inject() with same key in the current instance if it appears early.
3 participants