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

BUG: Don't loop over objects with a for in loop #3006

Closed
ashercoren opened this issue Sep 7, 2020 · 1 comment
Closed

BUG: Don't loop over objects with a for in loop #3006

ashercoren opened this issue Sep 7, 2020 · 1 comment

Comments

@ashercoren
Copy link
Contributor

Version: 0.16.22

Are you able to reproduce the bug from the demo?

[-] Yes
[ ] No

What is the expected behavior?
Looping over objects should be done using Object.keys.forEach..., and not with a for-in loop.

Looping over objects with a for in loop will include properties that are inherited through the prototype chain. This behavior can lead to unexpected items in your for loop.
More details can be found here.

Are you able to attach screenshots, screencasts or a live demo?

[ ] Yes (attach)
[-] No

@ashercoren
Copy link
Contributor Author

This caused a bug in our application since we are using some package that adds properties to the object prototype.
When trying to initialize a grapes.js editor we get an error in the console.

image

@artf artf closed this as completed in d75f1f8 Sep 8, 2020
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

No branches or pull requests

1 participant