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: 849 support Symbol keys in provide/inject #850

Merged

Conversation

eriklumme1
Copy link
Contributor

@eriklumme1 eriklumme1 commented Oct 4, 2024

Closes: #849

As Object.entries(...) only lists string properties, and Vue supports provide/inject with Symbols as keys, all provisions are not picked up.

I opted for Reflect.ownKeys, as its a good choice per the MDN documentation:

Object.entries()

The Object.entries() static method returns an array of a given object's own enumerable string-keyed property key-value pairs.

Reflect.ownKeys()

The Reflect.ownKeys() static method returns an array of the target object's own property keys

Return Value
Array of the target object's own property keys, including strings and symbols. For most objects, the array will be in the order of:

I've modified the #732 example to add the symbols. Prior to my change, this is the output:

Screenshot 2024-10-04 at 15 10 29

And with my changes it's this

Screenshot 2024-10-04 at 15 19 37

Copy link

netlify bot commented Oct 4, 2024

Deploy Preview for tresjs-docs ready!

Name Link
🔨 Latest commit e4be495
🔍 Latest deploy log https://app.netlify.com/sites/tresjs-docs/deploys/66ffe07975dc4a0008f58952
😎 Deploy Preview https://deploy-preview-850--tresjs-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@eriklumme1 eriklumme1 changed the title support Symbol keys in provide/inject (fix #849) fix: 849 support Symbol keys in provide/inject Oct 4, 2024
@eriklumme1 eriklumme1 changed the title fix: 849 support Symbol keys in provide/inject fix: #849 support Symbol keys in provide/inject Oct 4, 2024
@eriklumme1 eriklumme1 changed the title fix: #849 support Symbol keys in provide/inject fix: 849 support Symbol keys in provide/inject Oct 4, 2024
@alvarosabu alvarosabu self-assigned this Oct 12, 2024
@alvarosabu alvarosabu added p4-important-bug Violate documented behavior or significantly improve performance (priority) bug Something isn't working labels Oct 12, 2024
@alvarosabu alvarosabu merged commit 35125ce into Tresjs:main Oct 12, 2024
8 of 9 checks passed
@alvarosabu
Copy link
Member

@eriklumme1 thanks a lot for raising this and providing a working solution. You are awesome

@eriklumme1
Copy link
Contributor Author

@alvarosabu thanks a lot for getting this in!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working p4-important-bug Violate documented behavior or significantly improve performance (priority)
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Provide/Inject from Vue component not working with Symbol keys
2 participants