tenderlove/nokogiri — Issue #546: XML::Document#add_child unduly restricts its parameter's type
Author: alexch
Created: 2011-10-08 00:24:42+00:00
State: open

Node#add_child is fine with lots of different types of child -- strings, nodesets, etc...

https://github.com/tenderlove/nokogiri/blob/master/lib/nokogiri/xml/node.rb#L265

...but XML::Document#add_child fails if its parameter doesn't have a "type" method

https://github.com/tenderlove/nokogiri/blob/master/lib/nokogiri/xml/document.rb#L207

This is the sound of the duck typing duck quacking sadly:

undefined method `type' for [#]:Nokogiri::XML::NodeSet

I haven't written a test and patch yet but I'd be happy to give it a shot (if I can get nokogiri to build locally).