diff --git a/lib/oga/xml/element.rb b/lib/oga/xml/element.rb index 26eabff..4696a05 100644 --- a/lib/oga/xml/element.rb +++ b/lib/oga/xml/element.rb @@ -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 ## diff --git a/spec/oga/xml/element_spec.rb b/spec/oga/xml/element_spec.rb index 67b4223..824e382 100644 --- a/spec/oga/xml/element_spec.rb +++ b/spec/oga/xml/element_spec.rb @@ -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