Browse files

[BUGFIX] Set the namespace when inheriting more correctly

* Allow nokogiri to do its usual checking
  • Loading branch information...
1 parent 83b0c22 commit 26455758ca18267d620781e8f4ac4190eedf4728 @benlangfeld committed Apr 1, 2012
Showing with 7 additions and 1 deletion.
  1. +1 −1 lib/niceogiri/xml/node.rb
  2. +6 −0 spec/niceogiri/xml/node_spec.rb
View
2 lib/niceogiri/xml/node.rb
@@ -132,7 +132,7 @@ def set_content_for(node, content = nil)
# @param [XML::Node] node the node to inherit
# @return [self]
def inherit(node)
- set_namespace node.namespace if node.namespace
+ nokogiri_namespace = node.namespace
inherit_attrs node.attributes
node.children.each { |c| self << c.dup }
self
View
6 spec/niceogiri/xml/node_spec.rb
@@ -145,6 +145,12 @@ module XML
n2.to_s.should == n.to_s
end
+ it 'holds on to namespaces without a prefix when inheriting content' do
+ n = Nokogiri::XML.parse('<message><bar:foo xmlns="http://bar.com"></message>').root
+ n2 = Node.new('message').inherit n
+ n2.to_s.should == n.to_s
+ end
+
it 'holds on to namespaces when inheriting attributes' do
n = Nokogiri::XML.parse('<foo xml:bar="http://bar.com"/>').root
n2 = Node.new('foo').inherit n

0 comments on commit 2645575

Please sign in to comment.