Fix buglet in xhtmldiff
Fixes one of two formely broken unit tests.
This commit is contained in:
parent
ad049bcc4b
commit
3929fceaf8
|
@ -86,6 +86,19 @@ class DiffTest < Test::Unit::TestCase
|
||||||
assert_equal "<ins class='diffins'><div>foo</div></ins>", diff(a, b)
|
assert_equal "<ins class='diffins'><div>foo</div></ins>", diff(a, b)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_diff_for_tag_change
|
||||||
|
a = "<a>x</a>"
|
||||||
|
b = "<b>x</b>"
|
||||||
|
assert_equal "<del class='diffmod'><a>x</a></del><ins class='diffmod'><b>x</b></ins>", diff(a, b)
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_diff_for_tag_change_II
|
||||||
|
a = "<ul>\n<li>x</li>\n<li>y</li>\n</ul>"
|
||||||
|
b = "<ol>\n<li>x</li>\n<li>y</li>\n</ol>"
|
||||||
|
assert_equal "<del class='diffmod'><ul>\n<li>x</li>\n<li>y</li>\n</ul>" +
|
||||||
|
"</del><ins class='diffmod'><ol>\n<li>x</li>\n<li>y</li>\n</ol></ins>", diff(a, b)
|
||||||
|
end
|
||||||
|
|
||||||
# FIXME this test fails (ticket #67, http://dev.instiki.org/ticket/67)
|
# FIXME this test fails (ticket #67, http://dev.instiki.org/ticket/67)
|
||||||
def test_html_diff_preserves_endlines_in_pre
|
def test_html_diff_preserves_endlines_in_pre
|
||||||
a = "<pre>a\nb\nc\n</pre>"
|
a = "<pre>a\nb\nc\n</pre>"
|
||||||
|
@ -94,12 +107,5 @@ class DiffTest < Test::Unit::TestCase
|
||||||
"<pre><span> a\n<del class='diffdel'>b\nc\n</del></span></pre>",
|
"<pre><span> a\n<del class='diffdel'>b\nc\n</del></span></pre>",
|
||||||
diff(a, b))
|
diff(a, b))
|
||||||
end
|
end
|
||||||
|
|
||||||
# FIXME. xhtmldiff fails to detect any change here
|
|
||||||
def test_diff_for_tag_change
|
|
||||||
a = "<a>x</a>"
|
|
||||||
b = "<b>x</b>"
|
|
||||||
assert_equal "<del class='diffdel'><a>x</a></del><ins class='diffins'><b>x</b></ins>", diff(a, b)
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
3
vendor/plugins/xhtmldiff/lib/xhtmldiff.rb
vendored
3
vendor/plugins/xhtmldiff/lib/xhtmldiff.rb
vendored
|
@ -7,6 +7,7 @@
|
||||||
# Tweaks by Jacques Distler <distler@golem.ph.utexas.edu>
|
# Tweaks by Jacques Distler <distler@golem.ph.utexas.edu>
|
||||||
# -- add classnames to <del> and <ins> elements added by XHTMLDiff,
|
# -- add classnames to <del> and <ins> elements added by XHTMLDiff,
|
||||||
# for better CSS styling
|
# for better CSS styling
|
||||||
|
# -- detect change in element name, without change in content
|
||||||
|
|
||||||
require 'diff/lcs'
|
require 'diff/lcs'
|
||||||
require 'rexml/document'
|
require 'rexml/document'
|
||||||
|
@ -64,7 +65,7 @@ class XHTMLDiff
|
||||||
if a == b
|
if a == b
|
||||||
return a.deep_clone
|
return a.deep_clone
|
||||||
end
|
end
|
||||||
if REXML::HashableElementDelegator === a and REXML::HashableElementDelegator === b
|
if REXML::HashableElementDelegator === a and REXML::HashableElementDelegator === b and a.name == b.name
|
||||||
o = REXML::Element.new(a.name)
|
o = REXML::Element.new(a.name)
|
||||||
o.add_attributes a.attributes
|
o.add_attributes a.attributes
|
||||||
hd = self.new(o)
|
hd = self.new(o)
|
||||||
|
|
Loading…
Reference in a new issue