jQuery.PrettyTextDiff icon indicating copy to clipboard operation
jQuery.PrettyTextDiff copied to clipboard

When one of settings.originalContent && settings.changedContent are empty

Open paolof76 opened this issue 10 years ago • 0 comments

When one of the two values are empty, the diff is not shown in case of originalContent and changedContent are passed as parameters.

Example (pass an empty originalContent):

$("input[type=button2]").click(function () { $("#wrapper tr").prettyTextDiff({ cleanup: $("#cleanup").is(":checked"), originalContent: "", changedContent: "Some more text which can be passed to this function.", diffContainer: ".diff2" }); });

A quick fix I found to let it work is to split the if (settings.originalContent && settings.changedContent) {} in two separate checks: if (settings.originalContent) { original = $('

').html(settings.originalContent).text(); } else { original = $(settings.originalContainer, this).text(); } if (settings.changedContent) { changed = $('
').html(settings.changedContent).text(); } else { changed = $(settings.changedContainer, this).text(); }

paolof76 avatar Aug 05 '15 21:08 paolof76