public
Rubygem
Description: a humane, eval-safe templating system using Hpricot
Clone URL: git://github.com/mattly/hpreserve.git
Search Repo:
Click here to lend your support to: hpreserve and make a donation at www.pledgie.com !
fix child not found for attr_on_child filter
mattly (author)
Mon May 12 15:18:22 -0700 2008
commit  e88d87815eff3d624235646dcbd8fb3f5e5b571c
tree    ca24be32c5c31f9582f499b95a58dc24fb7dbe63
parent  272ff8c5beade3371f627bdc8118ead3bfcf4296
...
49
50
51
52
 
 
53
54
55
...
49
50
51
 
52
53
54
55
56
0
@@ -49,7 +49,8 @@
0
     end
0
     
0
     def attr_on_child(node, child, attrib, value)
0
- node.at('#'+child).set_attribute(attrib, value)
0
+ child = node.at('#'+child)
0
+ child.set_attribute(attrib, value) if child
0
       node
0
     end
0
     
...
128
129
130
 
 
 
 
 
 
 
131
132
133
...
128
129
130
131
132
133
134
135
136
137
138
139
140
0
@@ -128,6 +128,13 @@
0
       @f.run 'attr_on_child', @doc.at('div'), 'foo', 'class', 'active'
0
       @doc.at('#foo').classes.should == ['active']
0
     end
0
+
0
+ it "handles a child not found" do
0
+ html = '<div><span id="bar">bar</span></div>'
0
+ @doc = Hpricot(html)
0
+ @f.run 'attr_on_child', @doc.at('div'), 'foo', 'class', 'active'
0
+ @doc.to_s.should == html
0
+ end
0
   end
0
   
0
 end

Comments

    No one has commented yet.