-
-
Notifications
You must be signed in to change notification settings - Fork 33.7k
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
Provided values in mixin are not accessible #9213
Labels
Comments
It doesn't seem to be related to Symbols but rather using var provideMixin1 = {
provide: {
foo: 'it is foo'
}
}
var Parent = {
mixin: [
provideMixin1,
],
template: '<div><slot /></div>'
}
var Child = {
inject: ['foo'],
template: '<div>foo: {{ foo }} bar:</div>',
}
new Vue({
components: {
Parent,
Child,
},
template: '<parent><child /></parent>'
}).$mount('#app') |
posva
changed the title
use provide with Symbol in mixins got error
Provided values in mixin are not accessible
Dec 17, 2018
I'm sorry that I got a typo... |
This is addressed by #7926 (pending merge for next minor) |
Ups, my bad, sorry! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Version
2.5.21
Reproduction link
https://codepen.io/anon/pen/oJLdMN
Open the link and see the error message in dev console.
Steps to reproduce
Create two mixins with a provide object using Symbol as it's key field. Then assign these mixins to a component.
What is expected?
The child component can access two provide object without any error.
What is actually happening?
The child component can only access the last provide object, while the first one is undefined.
Diving into the source code, the reason of this issue is that Vue uses
Object.keys
to iterate over theprovide
object while merging mixins. However,Object.keys
won't return Symbol keys. see the code.Maybe we should use
for ... in
loop, which will iterate through Symbol keys correctly.The text was updated successfully, but these errors were encountered: