Skip to content

Commit 35e05a0

Browse files
committedMar 11, 2022
fixes elm#32
Correct equality check on oneOf decoders for virtual DOM diffing.
1 parent 063aaf0 commit 35e05a0

File tree

1 file changed

+25
-2
lines changed

1 file changed

+25
-2
lines changed
 

‎src/Elm/Kernel/Json.js

+25-2
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,7 @@ function _Json_equality(x, y)
380380
return x.__index === y.__index && _Json_equality(x.__decoder, y.__decoder);
381381

382382
case __1_MAP:
383-
return x.__func === y.__func && _Json_listEquality(x.__decoders, y.__decoders);
383+
return x.__func === y.__func && _Json_arrayEquality(x.__decoders, y.__decoders);
384384

385385
case __1_AND_THEN:
386386
return x.__callback === y.__callback && _Json_equality(x.__decoder, y.__decoder);
@@ -390,7 +390,7 @@ function _Json_equality(x, y)
390390
}
391391
}
392392

393-
function _Json_listEquality(aDecoders, bDecoders)
393+
function _Json_arrayEquality(aDecoders, bDecoders)
394394
{
395395
var len = aDecoders.length;
396396
if (len !== bDecoders.length)
@@ -407,6 +407,29 @@ function _Json_listEquality(aDecoders, bDecoders)
407407
return true;
408408
}
409409

410+
function _Json_listEquality(aDecoders, bDecoders)
411+
{
412+
var tempA = aDecoders;
413+
var tempB = bDecoders;
414+
while (tempA.b)
415+
{
416+
if (!tempB.b)
417+
{
418+
return false;
419+
}
420+
if (!_Json_equality(tempA.a, tempB.a))
421+
{
422+
return false;
423+
}
424+
tempA = tempA.b;
425+
tempB = tempB.b;
426+
}
427+
if (tempB.b)
428+
{
429+
return false;
430+
}
431+
return true;
432+
}
410433

411434
// ENCODE
412435

0 commit comments

Comments
 (0)