Skip to content

Commit

Permalink
XML::DocumentFragment.parse supports kwargs
Browse files Browse the repository at this point in the history
Related to #3323
  • Loading branch information
openbl authored and flavorjones committed Dec 8, 2024
1 parent d3d96c2 commit c029eb6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/nokogiri/xml/document_fragment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class DocumentFragment < Nokogiri::XML::Node

class << self
# Create a Nokogiri::XML::DocumentFragment from +tags+
def parse(tags, options = ParseOptions::DEFAULT_XML, &block)
def parse(tags, options_ = ParseOptions::DEFAULT_XML, options: options_, &block)
new(XML::Document.new, tags, nil, options, &block)
end

Expand Down
10 changes: 10 additions & 0 deletions test/xml/test_document_fragment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,16 @@ def test_for_libxml_in_context_memory_badness_when_encountering_encoding_errors
end
end

it "accepts kwargs" do
frag = Nokogiri::XML::DocumentFragment.parse(input, options: xml_default)
assert_equal("<a>foo</a>", frag.to_html)
refute_empty(frag.errors)

assert_raises(Nokogiri::SyntaxError) do
Nokogiri::XML::DocumentFragment.parse(input, options: xml_strict)
end
end

it "takes a config block" do
default_config = nil
Nokogiri::XML::DocumentFragment.parse(input) do |config|
Expand Down

0 comments on commit c029eb6

Please sign in to comment.