Changeset 166
- Timestamp:
- 08/26/2008 21:06:37 (3 months ago)
- Location:
- trunk
- Files:
-
- 2 modified
-
lib/hpricot/traverse.rb (modified) (2 diffs)
-
test/test_parser.rb (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/hpricot/traverse.rb
r161 r166 285 285 nodes = [self] 286 286 else 287 m = expr.match(%r!^([# .]?)([a-z0-9\\*_-]*)!i).to_a287 m = expr.match(%r!^([#\@.]?)([a-z0-9\\*_-]*)!i).to_a 288 288 after = $' 289 289 mt = after[%r!:[a-z0-9\\*_-]+!i, 0] … … 297 297 oid = get_element_by_id(m[2]) 298 298 nodes = oid ? [oid] : [] 299 expr = after 300 elsif m[1] == '@' 301 ret = [] 302 nodes.each do |node| 303 ret << node.parent.get_attribute(m[2]) 304 end 305 nodes = ret 299 306 expr = after 300 307 else -
trunk/test/test_parser.rb
r161 r166 74 74 assert_equal 'link1', (doc/:p/:a).first['id'] 75 75 assert_equal 'link1', doc.search('p').at('a').get_attribute('id') 76 assert_equal 'link1', doc.at("//a/@id") 76 77 assert_equal 'link2', (doc/'p').filter('.ohmy').search('a').first.get_attribute('id') 77 78 assert_equal (doc/'p')[2], (doc/'p').filter(':nth(2)')[0]
