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

Using for...in to loop on Arrays may break if Array.prototype is modified by the app #1539

Closed
efattal opened this issue Jun 14, 2019 · 4 comments

Comments

@efattal
Copy link

efattal commented Jun 14, 2019

Problem:

I would like to use Sortable in a WebComponent inside an app where old frameworks that I can hardly remove (PrototypeJS and ExtJS 3.4) override Array.prototype. Hence, Sortable breaks on drag-dropping when looping on arrays (like _detectNearestEmptySortable on sortables).

I submit a Pull Request that fixes the issue.
#1540

JSBin/JSFiddle demonstrating the problem:

http://jsfiddle.net/efattal/zv2h8bnx/1/

efattal pushed a commit to efattal/Sortable that referenced this issue Jun 14, 2019
efattal pushed a commit to efattal/Sortable that referenced this issue Jun 14, 2019
@imnottherobot
Copy link

I have same issue

@owen-m1
Copy link
Member

owen-m1 commented Jun 17, 2019

Why does that even break the for...in loop?

@efattal
Copy link
Author

efattal commented Jun 17, 2019

It's reproducible in the fiddle. Just look at JS errors in devtools and you'll see. for...in gets added members as keys while the code is only expecting positions in the array. Hence it gets undefined values from the array.

owen-m1 added a commit that referenced this issue Jun 23, 2019
@owen-m1
Copy link
Member

owen-m1 commented Jun 23, 2019

Solved in commit 854fed7.

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

3 participants