Skip to content

Commit 6be51d4

Browse files
committed
Avoid terminal equality checks in array mode
1 parent 30e141e commit 6be51d4

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

src/diff/base.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -145,9 +145,6 @@ Diff.prototype = {
145145

146146
equals(left, right) {
147147
if (this.options.comparator) {
148-
if (Array.isArray(right)) {
149-
right = right[0];
150-
}
151148
return this.options.comparator(left, right);
152149
} else {
153150
return left === right
@@ -215,10 +212,12 @@ function buildValues(diff, components, newString, oldString, useLongestToken) {
215212
}
216213
}
217214

218-
// Special case handle for when one terminal is ignored. For this case we merge the
219-
// terminal into the prior string and drop the change.
215+
// Special case handle for when one terminal is ignored (i.e. whitespace).
216+
// For this case we merge the terminal into the prior string and drop the change.
217+
// This is only available for string mode.
220218
let lastComponent = components[componentLen - 1];
221219
if (componentLen > 1
220+
&& typeof lastComponent.value === 'string'
222221
&& (lastComponent.added || lastComponent.removed)
223222
&& diff.equals('', lastComponent.value)) {
224223
components[componentLen - 2].value += lastComponent.value;

0 commit comments

Comments
 (0)