Environment
Describe the bug
In JavaScript, NaN === NaN evaluates to false. A consequence of this is that a signal with the value NaN will trigger an update if the value is again assigned as NaN. In the worst case, this might lead to an infinite loop with a two-way UI binding if the receiving end is also treating NaN in the same way.
To Reproduce
const x = signal(0);
effect(() => console.log(x.value));
x.value = NaN;
x.value = x.value;
This logs NaN twice even though it's expected that the last row shouldn't lead to running the effect again.
Expected behavior
Expected that the dirty checking logic has a special case for re-assigning NaN
Environment
@preact/signals-core@preact/signals@preact/signals-reactDescribe the bug
In JavaScript,
NaN === NaNevaluates tofalse. A consequence of this is that a signal with the valueNaNwill trigger an update if the value is again assigned asNaN. In the worst case, this might lead to an infinite loop with a two-way UI binding if the receiving end is also treatingNaNin the same way.To Reproduce
This logs
NaNtwice even though it's expected that the last row shouldn't lead to running the effect again.Expected behavior
Expected that the dirty checking logic has a special case for re-assigning
NaN