jonathanperret / paysage

Paysage is a visual shared playground for code.
http://paysage.xyz
GNU Affero General Public License v3.0
19 stars 8 forks source link

Sending objects list as JS object makes order unreliable #85

Closed juliendorra closed 7 years ago

juliendorra commented 7 years ago

Order of objects in the list in the programmer is not guaranteed, as the list is send as a Javascript object, not an Array or a (newer) Map object. An example is integers in Chrome: they are considered index, and treated before non-index

Example, try that on Chrome:

The behavior should be different on Firefox.

Some context: https://stackoverflow.com/a/23202095

We should send or transform the objects list as an array or map object to get a reliable order.

jonathanperret commented 7 years ago

Thanks, I can’t believe I missed this. Since order is important to us, arrays seem the right solution here (apart from partial browser support and having to insert entries in the order you want them, you can’t “send” a Map unless you define an unequivocal serialization format for them).