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 committed Nov 14, 2024
1 parent 64bb0b1 commit 9dd0946
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 @@ -11,7 +11,7 @@ class DocumentFragment < Nokogiri::XML::Node

####
# Create a Nokogiri::XML::DocumentFragment from +tags+
def self.parse(tags, options = ParseOptions::DEFAULT_XML, &block)
def self.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 9dd0946

Please sign in to comment.