File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -266,7 +266,7 @@ const getExampleJson = function () {
266266 return json ;
267267} ;
268268
269- const instance = jsondiffpatch . create ( {
269+ const diffOptions = {
270270 objectHash : function ( obj , index ) {
271271 const objRecord = obj as Record < string , string > ;
272272 if ( typeof objRecord . _id !== 'undefined' ) {
@@ -283,6 +283,13 @@ const instance = jsondiffpatch.create({
283283 }
284284 return '$$index:' + index ;
285285 } ,
286+ } as jsondiffpatch . Options ;
287+ const instance = jsondiffpatch . create ( diffOptions ) ;
288+ const instanceWithNoTextDiff = jsondiffpatch . create ( {
289+ ...diffOptions ,
290+ textDiff : {
291+ minLength : Number . MAX_VALUE ,
292+ } ,
286293} ) ;
287294
288295const dom = {
@@ -504,7 +511,12 @@ const compare = function () {
504511 const jsondifflength = document . getElementById ( 'jsondifflength' ) ! ;
505512 const jsonpatchlength = document . getElementById ( 'jsonpatchlength' ) ! ;
506513 try {
507- const delta = instance . diff ( left , right ) ;
514+ // jsonpatch format doesn't support textdiffs
515+ const noTextDiff = selectedType === 'jsonpatch' ;
516+ const delta = ( noTextDiff ? instanceWithNoTextDiff : instance ) . diff (
517+ left ,
518+ right ,
519+ ) ;
508520 resultsSections . setAttribute (
509521 'data-diff' ,
510522 typeof delta === 'undefined' ? 'no-diff' : 'has-diff' ,
You can’t perform that action at this time.
0 commit comments