Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid using diff container #21

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions jquery.pretty-text-diff.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,11 @@ $.fn.extend
dmp = new diff_match_patch();
@each ->
if settings.originalContent and settings.changedContent
containers = false
original = $('<div />').html(settings.originalContent).text()
changed = $('<div />').html(settings.changedContent).text()
else
containers = true
original = $(settings.originalContainer, this).text()
changed = $(settings.changedContainer, this).text()

Expand All @@ -35,8 +37,13 @@ $.fn.extend
$.fn.prettyTextDiff.debug "Diffs: ", diffs, settings

diff_as_html = $.map(diffs, (diff) ->
$.fn.prettyTextDiff.createHTML(diff))
$(settings.diffContainer, this).html(diff_as_html.join(''));
$.fn.prettyTextDiff.createHTML(diff)).join('')
if settings.diffContainer
$(settings.diffContainer, this).html(diff_as_html);
else
if containers
$(settings.originalContainer, this).html(diff_as_html).find('ins').remove();
$(settings.changedContainer, this).html(diff_as_html).find('del').remove();

@

Expand Down