arqex / freezer

A tree data structure that emits events on updates, even if the modification is triggered by one of the leaves, making it easier to think in a reactive way.
MIT License
1.28k stars 56 forks source link

Error appending values to array #34

Closed aptheod closed 9 years ago

aptheod commented 9 years ago

Hello,

I have a problem appending values to frozen data array. Let's say i have the data structure below:

var dataStore = new Freezer({ data: { array_1: [], int_value: 0, array_2: [], bool_value: false
} });

// Now we get the data from 'dataStore' and proceed to value assignment.

var newData = dataStore.get().data; newData.array_1.append( [1, 2, 3] );

// 'bool_value' and 'int_value' also get assigned with [1, 2, 3]. End up having the following structure: // data: { // array_1: [1, 2, 3], // int_value: [1, 2, 3], // array_2: [], // bool_value: [1, 2, 3]
// }

Debugging step by step found that on 'frozen.js' line 361 ( if( child == oldChild ) { child = newChild; } ), the '==' should be '===' to check the data type also, so fixed it temporarily.

arqex commented 9 years ago

Nice catch! Thanks for warn about it, I will fix it ASAP!

arqex commented 9 years ago

Hi @aptheod This has been fixed in v0.5.2, thanks for your help, you can update now.