# frozen_string_literal: true module Nokogiri module HTML4 class DocumentFragment < Nokogiri::XML::DocumentFragment #### # Create a Nokogiri::XML::DocumentFragment from +tags+, using +encoding+ def self.parse(tags, encoding = nil, options = XML::ParseOptions::DEFAULT_HTML, &block) doc = HTML4::Document.new encoding ||= if tags.respond_to?(:encoding) encoding = tags.encoding if encoding == ::Encoding::ASCII_8BIT "UTF-8" else encoding.name end else "UTF-8" end doc.encoding = encoding new(doc, tags, nil, options, &block) end def initialize(document, tags = nil, ctx = nil, options = XML::ParseOptions::DEFAULT_HTML) return self unless tags options = Nokogiri::XML::ParseOptions.new(options) if Integer === options yield options if block_given? if ctx preexisting_errors = document.errors.dup node_set = ctx.parse("