Changeset 94

Show
Ignore:
Timestamp:
01/27/2007 11:28:40 (23 months ago)
Author:
why
Message:
  • lib/hpricot/parse.rb: bogus end tags were being created incorrectly. the name was an array. and *DUCK* typing allowed this!!! solves #51.
  • lib/hpricot/elements.rb: okay this is a dumb one and is going to mix everyone up. xpath array indices start with 1. i know. hpricot was starting with 0. terrible me.
  • lib/hpricot/traverse.rb: ditto. but in xpath method.
Location:
trunk
Files:
4 modified

Legend:

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

    r89 r94  
    209209 
    210210            if m[0] == '[' && m[1] =~ /^\d+$/ 
    211                 m = [":", "nth", m[1]] 
     211                m = [":", "nth", m[1].to_i-1] 
    212212            end 
    213213 
  • trunk/lib/hpricot/parse.rb

    r87 r94  
    119119        end 
    120120        unless matched_elem 
    121           stack.last[2] << [:bogus_etag, token] 
     121          stack.last[2] << [:bogus_etag, token.first, token.last] 
    122122        else 
    123123          ele = stack.pop 
  • trunk/lib/hpricot/traverse.rb

    r92 r94  
    162162        end 
    163163        p = File.join(parent.xpath, self.pathname) 
    164         p += "[#{id}]" if sim >= 2 
     164        p += "[#{id+1}]" if sim >= 2 
    165165        p 
    166166      end 
  • trunk/test/test_parser.rb

    r88 r94  
    5454    assert_equal 'link2', (doc/'p').filter('.ohmy').search('a').first.get_attribute('id') 
    5555    assert_equal (doc/'p')[2], (doc/'p').filter(':nth(2)')[0] 
    56     assert_equal (doc/'p')[2], (doc/'p').filter('[2]')[0] 
     56    assert_equal (doc/'p')[2], (doc/'p').filter('[3]')[0] 
    5757    assert_equal 4, (doc/'p').filter('*').length 
    5858    assert_equal 4, (doc/'p').filter('* *').length