Ignore default NS when serializing elements.
When a default namespace is set (using xmlns="...") the method XML::Element#to_xml should _not_ include the namespace prefix in the output.
This commit is contained in:
parent
1abba1be9c
commit
795e669632
|
@ -211,7 +211,7 @@ module Oga
|
|||
# @return [String]
|
||||
#
|
||||
def to_xml
|
||||
ns = namespace ? "#{namespace}:" : ''
|
||||
ns = namespace_name ? "#{namespace_name}:" : ''
|
||||
body = children.map(&:to_xml).join('')
|
||||
attrs = ''
|
||||
|
||||
|
|
|
@ -315,6 +315,16 @@ describe Oga::XML::Element do
|
|||
|
||||
instance.to_xml.should == '<p><!--foo--></p>'
|
||||
end
|
||||
|
||||
example 'generate the corresponding XML when using a default namespace' do
|
||||
namespace = Oga::XML::Namespace.new(:name => 'xmlns', :uri => 'foo')
|
||||
instance = described_class.new(
|
||||
:name => 'foo',
|
||||
:namespaces => {'xmlns' => namespace}
|
||||
)
|
||||
|
||||
instance.to_xml.should == '<foo></foo>'
|
||||
end
|
||||
end
|
||||
|
||||
context '#inspect' do
|
||||
|
|
Loading…
Reference in New Issue