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
bug: nodes of value 0 get affected while updating its empty-array sibling #106
let frozen = new Freezer({
a: 0,
b: []
});
frozen.get().b.set(0, 0);
console.log(frozen.get())
You got {"a":[0],"b":[0]}. The node 'a' was affected, which wasn't what we expected.
I digged into the code and found out that in function 'refresh' , if (child == oldChild) was used to find the child node that should be updated.
Unfortunately 0==[] returns true, which has caused property 'a' to be updated together with property 'b'.
This could be fixed by using === instead.
Run the following code:
You got
{"a":[0],"b":[0]}
. The node 'a' was affected, which wasn't what we expected. I digged into the code and found out that in function 'refresh' ,if (child == oldChild)
was used to find the child node that should be updated. Unfortunately0==[]
returns true, which has caused property 'a' to be updated together with property 'b'. This could be fixed by using===
instead.