Changeset 132

Show
Ignore:
Timestamp:
04/04/2007 00:12:24 (20 months ago)
Author:
why
Message:
  • lib/hpricot/elements.rb: Elements#wrap now reparents okay (from piers in #54)
Location:
trunk
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • trunk/lib/hpricot/elements.rb

    r130 r132  
    168168        x.parent.replace_child(x, wrap) 
    169169        nest = nest.children.first until nest.empty? 
    170         nest.children << x 
     170        nest.html(nest.children + [x]) 
    171171      end 
    172172    end 
  • trunk/test/test_alter.rb

    r112 r132  
    1919    assert_equal 'test_inf.css', @basic.search("link")[-1].attributes['href'] 
    2020  end 
     21 
     22  def test_wrap 
     23    @basic = Hpricot.parse(TestFiles::BASIC) 
     24    ohmy = (@basic/"p.ohmy").wrap("<div id='wrapper'></div>") 
     25    assert_equal 'wrapper', ohmy[0].parent['id'] 
     26    assert_equal 'ohmy', Hpricot(@basic.to_html).at("#wrapper").children[0]['class'] 
     27  end 
    2128end