Permalink
Browse files

Processing instructions can now be added via Node#add_next_sibling.

This completes the fix begun in 0ea3e76.
  • Loading branch information...
1 parent 46fcdf9 commit 1dac5801b25fdec4dab93161b601d5cb05372a1e @flavorjones flavorjones committed Jun 21, 2014
Showing with 9 additions and 2 deletions.
  1. +1 −0 CHANGELOG.ja.rdoc
  2. +1 −0 CHANGELOG.rdoc
  3. +1 −1 lib/nokogiri/xml/node.rb
  4. +6 −1 test/xml/test_unparented_node.rb
View
@@ -6,6 +6,7 @@
* [MRI] Fix segfault during GC when using `libxml-ruby` and `nokogiri` together in multi-threaded environment. #895 (Thanks, @ender672!)
* Building on OSX 10.9 stock ruby 2.0.0 now works. #1101 (Thanks, @zenspider!)
* Node#parse now works again for HTML document nodes (broken in 1.6.2+).
+* Processing instructions can now be added via Node#add_next_sibling.
=== 1.6.2.1 / 2014年5月13日
View
@@ -6,6 +6,7 @@
* [MRI] Fix segfault during GC when using `libxml-ruby` and `nokogiri` together in multi-threaded environment. #895 (Thanks, @ender672!)
* Building on OSX 10.9 stock ruby 2.0.0 now works. #1101 (Thanks, @zenspider!)
* Node#parse now works again for HTML document nodes (broken in 1.6.2+).
+* Processing instructions can now be added via Node#add_next_sibling.
=== 1.6.2.1 / 2014-05-13
@@ -326,7 +326,7 @@ def add_previous_sibling node_or_tags
#
# Also see related method +after+.
def add_next_sibling node_or_tags
- raise ArgumentError.new("A document may not have multiple root nodes.") if parent.is_a?(XML::Document)
+ raise ArgumentError.new("A document may not have multiple root nodes.") if parent.is_a?(XML::Document) && !node_or_tags.is_a?(XML::ProcessingInstruction)
add_sibling :next, node_or_tags
end
@@ -248,12 +248,17 @@ def test_add_previous_sibling_to_root_raises_exception
end
end
- def test_add_pi_as_previous_sibling_to_root_is_ok
+ def test_add_pi_as_previous_and_next_sibling_to_root_is_ok
doc = Nokogiri::XML "<root>foo</root>"
pi = Nokogiri::XML::ProcessingInstruction.new(doc, "xml-stylesheet", %q{type="text/xsl" href="foo.xsl"})
doc.root.add_previous_sibling pi
expected_doc = %Q{<?xml version="1.0"?>\n<?xml-stylesheet type="text/xsl" href="foo.xsl"?>\n<root>foo</root>}
assert_includes doc.to_xml, expected_doc
+
+ pi2 = Nokogiri::XML::ProcessingInstruction.new(doc, "xml-stylesheet", %q{type="text/xsl" href="foo2.xsl"})
+ pi.add_next_sibling pi2
+ expected_doc = %Q{<?xml version="1.0"?>\n<?xml-stylesheet type="text/xsl" href="foo.xsl"?>\n<?xml-stylesheet type="text/xsl" href="foo2.xsl"?>\n<root>foo</root>}
+ assert_includes doc.to_xml, expected_doc
end
def test_find_by_css_with_tilde_eql

0 comments on commit 1dac580

Please sign in to comment.