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:
Yorick Peterse 2015-03-03 13:13:05 +01:00
parent 503efc32cd
commit 142b467277
2 changed files with 7 additions and 1 deletions

View File

@ -213,7 +213,7 @@ module Oga
#
def inner_text=(text)
text_node = XML::Text.new(:text => text)
@children = NodeSet.new([text_node])
@children = NodeSet.new([text_node], self)
end
##

View File

@ -268,6 +268,12 @@ describe Oga::XML::Element do
@element.children.length.should == 1
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
describe '#text_nodes' do