Permalink
Browse files

fixes #7896 -- HTML::Document was failing to generate final closing t…

…ag when it should have been inferred
  • Loading branch information...
1 parent 1c534c6 commit 1803de2fff8bf1b1c75036b531f29411bdae5e8c @betesh betesh committed Oct 10, 2012
@@ -47,6 +47,7 @@ def initialize(text, strict=false, xml=false)
end
end
end
+ node_stack.last.children << Text.new(node_stack.last, node.line, node.position, "") if node_stack.length > 1 && node_stack.last.children.empty?
end
# Search the tree for (and return) the first node that matches the given
@@ -36,11 +36,7 @@ def form_text(action = "http://www.example.com", options = {})
def whole_form(action = "http://www.example.com", options = {})
out = form_text(action, options) + hidden_fields(options)
-
- if block_given?
- out << yield << "</form>"
- end
-
+ out << yield if block_given?
out
end
@@ -94,6 +94,26 @@ def test_tag_nesting_tag_to_s
assert_equal "<tag><nested /></tag>", doc.root.to_s
end
+ def test_tag_implicit_closing_tag_nesting_nothing_to_s
+ doc = HTML::Document.new("<tag>")
+ assert_equal "<tag></tag>", doc.root.to_s
+ end
+
+ def test_tag_implicit_closing_tag_nesting_space_to_s
+ doc = HTML::Document.new("<tag> ")
+ assert_equal "<tag> </tag>", doc.root.to_s
+ end
+
+ def test_tag_implicit_closing_tag_nesting_text_to_s
+ doc = HTML::Document.new("<tag>text")
+ assert_equal "<tag>text</tag>", doc.root.to_s
+ end
+
+ def test_tag_implicit_closing_tag_nesting_tag_to_s
+ doc = HTML::Document.new("<tag><nested />")
+ assert_equal "<tag><nested /></tag>", doc.root.to_s
+ end
+
def test_parse_cdata
doc = HTML::Document.new(<<-HTML)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
@@ -14,6 +14,7 @@ def test_open_with_attributes
assert_equal "hey_ho", node["foo"]
assert_equal "blah blah", node["x:bar"]
assert_equal "blah blah blah", node["baz"]
+ assert_nil node.closing
end
def test_self_closing_without_attributes

0 comments on commit 1803de2

Please sign in to comment.