@@ -36,7 +36,7 @@ Diff.prototype = {
3636 let oldPos = this . extractCommon ( bestPath [ 0 ] , newString , oldString , 0 ) ;
3737 if ( bestPath [ 0 ] . newPos + 1 >= newLen && oldPos + 1 >= oldLen ) {
3838 // Identity per the equality and tokenizer
39- return done ( [ { value : newString . join ( '' ) , count : newString . length } ] ) ;
39+ return done ( [ { value : this . join ( newString ) , count : newString . length } ] ) ;
4040 }
4141
4242 // Main worker method. checks all permutations of a given edit length for acceptance.
@@ -160,6 +160,9 @@ Diff.prototype = {
160160 } ,
161161 tokenize ( value ) {
162162 return value . split ( '' ) ;
163+ } ,
164+ join ( chars ) {
165+ return chars . join ( '' ) ;
163166 }
164167} ;
165168
@@ -179,9 +182,9 @@ function buildValues(diff, components, newString, oldString, useLongestToken) {
179182 return oldValue . length > value . length ? oldValue : value ;
180183 } ) ;
181184
182- component . value = value . join ( '' ) ;
185+ component . value = diff . join ( value ) ;
183186 } else {
184- component . value = newString . slice ( newPos , newPos + component . count ) . join ( '' ) ;
187+ component . value = diff . join ( newString . slice ( newPos , newPos + component . count ) ) ;
185188 }
186189 newPos += component . count ;
187190
@@ -190,7 +193,7 @@ function buildValues(diff, components, newString, oldString, useLongestToken) {
190193 oldPos += component . count ;
191194 }
192195 } else {
193- component . value = oldString . slice ( oldPos , oldPos + component . count ) . join ( '' ) ;
196+ component . value = diff . join ( oldString . slice ( oldPos , oldPos + component . count ) ) ;
194197 oldPos += component . count ;
195198
196199 // Reverse add and remove so removes are output first to match common convention
0 commit comments