diff --git a/src/diff/base.js b/src/diff/base.js index bac0dbfe..8d8e14c2 100644 --- a/src/diff/base.js +++ b/src/diff/base.js @@ -1,6 +1,4 @@ -export default function Diff(ignoreWhitespace) { - this.ignoreWhitespace = ignoreWhitespace; -} +export default function Diff() {} Diff.prototype = { diff(oldString, newString, callback) { @@ -139,8 +137,7 @@ Diff.prototype = { }, equals(left, right) { - let reWhitespace = /\S/; - return left === right || (this.ignoreWhitespace && !reWhitespace.test(left) && !reWhitespace.test(right)); + return left === right; }, removeEmpty(array) { let ret = []; diff --git a/src/diff/word.js b/src/diff/word.js index 868a73de..10d6a008 100644 --- a/src/diff/word.js +++ b/src/diff/word.js @@ -20,7 +20,13 @@ import Diff from './base'; // Latin Extended Additional, 1E00–1EFF const extendedWordChars = /^[a-zA-Z\u{C0}-\u{FF}\u{D8}-\u{F6}\u{F8}-\u{2C6}\u{2C8}-\u{2D7}\u{2DE}-\u{2FF}\u{1E00}-\u{1EFF}]+$/u; -export const wordDiff = new Diff(true); +const reWhitespace = /\S/; + +export const wordDiff = new Diff(); +wordDiff.equals = function(left, right) { + return left === right || (!reWhitespace.test(left) && !reWhitespace.test(right)); +}; + export const wordWithSpaceDiff = new Diff(); wordDiff.tokenize = wordWithSpaceDiff.tokenize = function(value) { let tokens = value.split(/(\s+|\b)/);