Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Ticket #7641: html-scanner-parsing-empty-tag-pair.diff

File html-scanner-parsing-empty-tag-pair.diff, 1.8 kB (added by anthony.bailey, 2 years ago)
  • actionpack/test/controller/html-scanner/document_test.rb

    old new  
    7575    assert_not_nil doc.find(:tag => "div", :children => { :count => 1, :only => { :tag => "table" } }) 
    7676  end 
    7777 
     78  def test_tag_nesting_nothing_to_s 
     79    doc = HTML::Document.new("<tag></tag>") 
     80    assert_equal "<tag></tag>", doc.root.to_s 
     81  end 
     82 
     83  def test_tag_nesting_space_to_s 
     84    doc = HTML::Document.new("<tag> </tag>") 
     85    assert_equal "<tag> </tag>", doc.root.to_s 
     86  end 
     87 
     88  def test_tag_nesting_text_to_s 
     89    doc = HTML::Document.new("<tag>text</tag>") 
     90    assert_equal "<tag>text</tag>", doc.root.to_s 
     91  end 
     92 
     93  def test_tag_nesting_tag_to_s 
     94    doc = HTML::Document.new("<tag><nested /></tag>") 
     95    assert_equal "<tag><nested /></tag>", doc.root.to_s 
     96  end 
     97 
    7898  def test_parse_cdata 
    7999    doc = HTML::Document.new(<<-HTML) 
    80100<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" 
  • actionpack/lib/action_controller/vendor/html-scanner/html/document.rb

    old new  
    2222        if node.tag? 
    2323          if node_stack.length > 1 && node.closing == :close 
    2424            if node_stack.last.name == node.name 
     25              if node_stack.last.children.empty? 
     26                node_stack.last.children << Text.new(node_stack.last, node.line, node.position, "") 
     27              end 
    2528              node_stack.pop 
    2629            else 
    2730              open_start = node_stack.last.position - 20