Skip to content

Commit 2a2c4dd

Browse files
committed
if multiple groups are found of the same large size, prioritize the last one to avoid recursion issues
1 parent 433b534 commit 2a2c4dd

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

diffDOM.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@
373373
c2.forEach(function(c2Element, c2Index) {
374374
if (!marked1[c1Index] && !marked2[c2Index] && roughlyEqual(c1Element, c2Element, uniqueDescriptors, subsetsSame)) {
375375
matches[c1Index + 1][c2Index + 1] = (matches[c1Index][c2Index] ? matches[c1Index][c2Index] + 1 : 1);
376-
if (matches[c1Index + 1][c2Index + 1] > lcsSize) {
376+
if (matches[c1Index + 1][c2Index + 1] >= lcsSize) {
377377
lcsSize = matches[c1Index + 1][c2Index + 1];
378378
index = [c1Index + 1, c2Index + 1];
379379
}

tests/basic.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@
2323
<h1>Test for diffDOM</h1>
2424

2525
<!-- Add all divs to be compared here two by two -->
26-
<!--div><img><p></p><i></i><img></div>
26+
<div><img><p></p><i></i><img></div>
2727
<div><img><p>a</p><i></i><img><p></p></div>
2828

2929
<div><p></p><i></i><img></div>
30-
<div><img><p>a</p><i></i><img><p></p></div-->
30+
<div><img><p>a</p><i></i><img><p></p></div>
3131

3232
<div><img><img><p></p><i></i><canvas></div>
3333
<div><p></p><img><img><canvas></div>

0 commit comments

Comments
 (0)