| CODENOTIFIER | HelpYou are not signed inSign in |
Project: Hpricot
Revision: 160
Author: why
Date: 21 Feb 2008 14:36:48
Diff at Trac: http://code.whytheluckystiff.net/hpricot/changeset/160
Changes:* lib/hpricot/elements.rb: a more liberal xpath attr parsing from ticket #115. thanks, wrs!
Files:| ... | ...@@ -13,4 +13,13 @@ | |
| 13 | 13 | assert_equal ele, @basic.at(ele.xpath) |
| 14 | 14 | end |
| 15 | 15 | end |
| 16 | def test_attr_brackets | |
| 17 | doc = Hpricot('<input name="vendor[porkpies]"/>') | |
| 18 | assert_equal 1, (doc/'input[@name^="vendor[porkpies]"]').length | |
| 19 | assert_equal 1, (doc/'input[@name="vendor[porkpies]"]').length | |
| 20 | assert_equal 0, (doc/'input[@name$="]]]]]"]').length | |
| 21 | ||
| 22 | doc = Hpricot('<input name="vendor[porkpies][meaty]"/>') | |
| 23 | assert_equal 1, (doc/'input[@name^="vendor[porkpies][meaty]"]').length | |
| 24 | end | |
| 16 | 25 | end |
| ... | ...@@ -90,7 +90,7 @@ | |
| 90 | 90 | # turn arguments into children or attributes |
| 91 | 91 | childs = [] |
| 92 | 92 | attrs = args.grep(Hash) |
| 93 | childs.concat((args - attrs).map do |x| | |
| 93 | childs.concat((args - attrs).flatten.map do |x| | |
| 94 | 94 | if x.respond_to? :to_html |
| 95 | 95 | Hpricot.make(x.to_html) |
| 96 | 96 | elsif x |
| ... | ...@@ -261,7 +261,7 @@ | |
| 261 | 261 | self |
| 262 | 262 | end |
| 263 | 263 | |
| 264 | ATTR_RE = %r!\[ *(?:(@)([\w\(\)-]+)|([\w\(\)-]+\(\))) *([~\!\|\*$\^=]*) *'?"?([^\]'"]*)'?"? *\]!i | |
| 264 | ATTR_RE = %r!\[ *(?:(@)([\w\(\)-]+)|([\w\(\)-]+\(\))) *([~\!\|\*$\^=]*) *'?"?([^'"]*)'?"? *\]!i | |
| 265 | 265 | BRACK_RE = %r!(\[) *([^\]]*) *\]+!i |
| 266 | 266 | FUNC_RE = %r!(:)?([a-zA-Z0-9\*_-]*)\( *[\"']?([^ \)]*?)['\"]? *\)! |
| 267 | 267 | CUST_RE = %r!(:)([a-zA-Z0-9\*_-]*)()! |