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

inject misses this #3923

Closed
eunjae-lee opened this issue Jun 9, 2021 · 2 comments
Closed

inject misses this #3923

eunjae-lee opened this issue Jun 9, 2021 · 2 comments
Labels
❗ p4-important Priority 4: this fixes bugs that violate documented behavior, or significantly improves perf. 🐞 bug Something isn't working

Comments

@eunjae-lee
Copy link
Contributor

Version

3.1.1

Reproduction link

https://codesandbox.io/s/sleepy-frog-2zshk?file=/src/components/HelloWorld.vue:243-292

Steps to reproduce

Open the reproduction and you can see the error message in the console right after.

What is expected?

It's supposed to display

Hello Vue in CodeSandbox!

Component name: HelloWorld

That "HelloWorld" is supposed to come from this.$options.name.

What is actually happening?

this is undefined and it throws an error.


https://github.com/vuejs/vue-next/blob/9a5bdb15df454fe99b4f695c85a2890d3e059b68/packages/runtime-core/src/apiInject.ts#L63-L64

According to the latest version of apiInject.ts, defaultValue function is called without this binding. It should've been defaultValue.call(instance).

The same example works fine with Vue2.
https://codesandbox.io/s/purple-waterfall-hutku?file=/src/components/HelloWorld.vue:235-270

If it's not intended, I could open a PR for fix.

@posva posva added 🐞 bug Something isn't working ❗ p4-important Priority 4: this fixes bugs that violate documented behavior, or significantly improves perf. labels Jun 9, 2021
@yyx990803
Copy link
Member

Looks like an easy fix (it should be defaultValue.call(instance.proxy)) - PR welcome!

@eunjae-lee
Copy link
Contributor Author

Alright. PR coming!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
❗ p4-important Priority 4: this fixes bugs that violate documented behavior, or significantly improves perf. 🐞 bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants