Set parent of nodes set using Element#inner_text=
This ensures that any text nodes created using Element#inner_text= have their parent node set correctly.
This commit is contained in:
parent
503efc32cd
commit
142b467277
|
@ -213,7 +213,7 @@ module Oga
|
||||||
#
|
#
|
||||||
def inner_text=(text)
|
def inner_text=(text)
|
||||||
text_node = XML::Text.new(:text => text)
|
text_node = XML::Text.new(:text => text)
|
||||||
@children = NodeSet.new([text_node])
|
@children = NodeSet.new([text_node], self)
|
||||||
end
|
end
|
||||||
|
|
||||||
##
|
##
|
||||||
|
|
|
@ -268,6 +268,12 @@ describe Oga::XML::Element do
|
||||||
|
|
||||||
@element.children.length.should == 1
|
@element.children.length.should == 1
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'sets the parent node of the newly inserted text node' do
|
||||||
|
@element.inner_text = 'foo'
|
||||||
|
|
||||||
|
@element.children[0].parent.should == @element
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#text_nodes' do
|
describe '#text_nodes' do
|
||||||
|
|
Loading…
Reference in New Issue