Don't modify raw namespaces.

When calling Element#available_namespaces the list of namespaces returned by
Element#namespaces must not be modified.
This commit is contained in:
Yorick Peterse 2014-11-17 00:01:16 +01:00
parent a4459c866f
commit 804646cc5e
2 changed files with 5 additions and 1 deletions

View File

@ -273,7 +273,7 @@ module Oga
# @return [Hash]
#
def available_namespaces
merged = namespaces
merged = namespaces.dup
node = parent
while node && node.respond_to?(:namespaces)

View File

@ -418,6 +418,10 @@ describe Oga::XML::Element do
example 'return the "baz" namespace for the parent' do
@parent_ns['baz'].uri.should == 'yyy'
end
example 'do not modify the list of direct namespaces' do
@child.namespaces.key?('foo').should == false
end
end
context '#self_closing?' do