parent
739f885078
commit
746c8052dd
|
@ -3,6 +3,16 @@
|
|||
This document contains details of the various releases and their release dates.
|
||||
Dates are in the format `yyyy-mm-dd`.
|
||||
|
||||
## 0.3.0 - Unreleased
|
||||
|
||||
### Element Inner Text
|
||||
|
||||
When setting the inner text of an element using `Oga::XML::Element#inner_text=`
|
||||
_all_ child nodes of the element are now removed first, instead of only text
|
||||
nodes being removed.
|
||||
|
||||
See <https://github.com/YorickPeterse/oga/issues/64> for more information.
|
||||
|
||||
## 0.2.0 - 2014-11-17
|
||||
|
||||
### CSS Selector Support
|
||||
|
|
|
@ -212,11 +212,8 @@ module Oga
|
|||
# @param [String] text
|
||||
#
|
||||
def inner_text=(text)
|
||||
children.each do |child|
|
||||
child.remove if child.is_a?(Text)
|
||||
end
|
||||
|
||||
children << XML::Text.new(:text => text)
|
||||
text_node = XML::Text.new(:text => text)
|
||||
@children = NodeSet.new([text_node])
|
||||
end
|
||||
|
||||
##
|
||||
|
|
|
@ -260,11 +260,13 @@ describe Oga::XML::Element do
|
|||
@element.inner_text.should == 'foo'
|
||||
end
|
||||
|
||||
example 'remove existing text nodes before inserting new nodes' do
|
||||
example 'remove all existing nodes before inserting a new text node' do
|
||||
@element.children << Oga::XML::Text.new(:text => 'foo')
|
||||
@element.children << Oga::XML::Element.new(:name => 'x')
|
||||
|
||||
@element.inner_text = 'bar'
|
||||
@element.inner_text.should == 'bar'
|
||||
|
||||
@element.children.length.should == 1
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue