diff --git a/lib/nokogiri/xml/document_fragment.rb b/lib/nokogiri/xml/document_fragment.rb index 40cc8f4fa1..8469f5cec0 100644 --- a/lib/nokogiri/xml/document_fragment.rb +++ b/lib/nokogiri/xml/document_fragment.rb @@ -4,6 +4,8 @@ module Nokogiri module XML class DocumentFragment < Nokogiri::XML::Node + attr_reader :parse_options + #### # Create a Nokogiri::XML::DocumentFragment from +tags+ def self.parse(tags, options = ParseOptions::DEFAULT_XML, &block) @@ -20,6 +22,7 @@ def initialize(document, tags = nil, ctx = nil, options = ParseOptions::DEFAULT_ return self unless tags options = Nokogiri::XML::ParseOptions.new(options) if Integer === options + @parse_options = options yield options if block_given? children = if ctx diff --git a/test/html4/sax/test_document_error.rb b/test/html4/sax/test_document_error.rb index 513164148f..32387f1266 100644 --- a/test/html4/sax/test_document_error.rb +++ b/test/html4/sax/test_document_error.rb @@ -20,15 +20,10 @@ def start_document end def test_warning_document_encounters_error_but_terminates_normally - # Probably I'm doing something wrong, but I can't make nekohtml report errors, - # despite setting http://cyberneko.org/html/features/report-errors. - # See https://nekohtml.sourceforge.net/settings.html for more info. - # I'd love some help here if someone finds this comment and cares enough to dig in. - skip_unless_libxml2("nekohtml sax parser does not seem to report errors?") - warning_parser = Nokogiri::HTML4::SAX::Parser.new(Nokogiri::SAX::TestCase::Doc.new) warning_parser.parse("<
foo
", frag.to_html) - refute_empty(frag.errors) end it "accepts options" do frag = Nokogiri::HTML4::DocumentFragment.new(Nokogiri::HTML4::Document.new, input, nil, html4_default) + assert_equal html4_default, frag.parse_options assert_equal("
foo
", frag.to_html) - refute_empty(frag.errors) assert_raises(Nokogiri::SyntaxError) do Nokogiri::HTML4::DocumentFragment.new(Nokogiri::HTML4::Document.new, input, nil, html4_strict)