Skip to content

Commit 686e257

Browse files
committed
only permit maxChildDiffCount when we are not in the top element, related to #67
1 parent 02370f5 commit 686e257

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

diffDOM.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,7 @@
437437
debug: false,
438438
diffcap: 10, // Limit for how many diffs are accepting when debugging. Inactive when debug is false.
439439
maxDepth: false, // False or a numeral. If set to a numeral, limits the level of depth that the the diff mechanism looks for differences. If false, goes through the entire tree.
440-
maxChildCount: false, // False or a numeral. If set to a numeral, does not try to diff the contents of nodes with more children if there are more than maxChildDiffCount differences among child nodes.
440+
maxChildCount: 50, // False or a numeral. If set to a numeral, does not try to diff the contents of nodes with more children if there are more than maxChildDiffCount differences among child nodes.
441441
maxChildDiffCount: 3, // Numeral. See maxChildCount.
442442
valueDiffing: true, // Whether to take into consideration the values of forms that differ from auto assigned values (when a user fills out a form).
443443
// syntax: textDiff: function (node, currentValue, expectedValue, newValue)
@@ -629,7 +629,7 @@
629629
];
630630
}
631631

632-
if (this.maxChildCount && t1.childNodes && t2.childNodes && t1.childNodes.length > this.maxChildCount && t2.childNodes.length > this.maxChildCount) {
632+
if (route.length && this.maxChildCount && t1.childNodes && t2.childNodes && t1.childNodes.length > this.maxChildCount && t2.childNodes.length > this.maxChildCount) {
633633
var childNodesLength = t1.childNodes.length < t2.childNodes.length ? t1.childNodes.length : t2.childNodes.length, childDiffCount = 0, j = 0;
634634
while (childDiffCount < this.maxChildDiffCount && j < childNodesLength) {
635635
if (!isEqual(t1.childNodes[j], t2.childNodes[j])) {

tests/long-list.html

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,7 @@
3434
var dd = new diffDOM({
3535
debug: true,
3636
diffcap: 1000,
37-
valueDiffing: false,
38-
maxChildCount: false
37+
valueDiffing: false
3938
}),
4039
tl = new TraceLogger(dd), elements, first, second, third, fourth, theDiff;
4140

0 commit comments

Comments
 (0)