diff --git a/lib/nokogiri/xml/node.rb b/lib/nokogiri/xml/node.rb index 2e701a4d4f7..1780c6ceca7 100644 --- a/lib/nokogiri/xml/node.rb +++ b/lib/nokogiri/xml/node.rb @@ -847,9 +847,12 @@ def add_sibling next_or_previous, node_or_tags node_or_tags end + IS_BROKEN_LIBXML_VERSION = defined?(LIBXML_VERSION) && LIBXML_VERSION.start_with?('2.6').freeze + private_constant :IS_BROKEN_LIBXML_VERSION + def to_format save_option, options # FIXME: this is a hack around broken libxml versions - return dump_html if Nokogiri.uses_libxml? && %w[2 6] === LIBXML_VERSION.split('.')[0..1] + return dump_html if Nokogiri.uses_libxml? && IS_BROKEN_LIBXML_VERSION options[:save_with] = save_option unless options[:save_with] serialize(options) @@ -857,7 +860,7 @@ def to_format save_option, options def write_format_to save_option, io, options # FIXME: this is a hack around broken libxml versions - return (io << dump_html) if Nokogiri.uses_libxml? && %w[2 6] === LIBXML_VERSION.split('.')[0..1] + return (io << dump_html) if Nokogiri.uses_libxml? && IS_BROKEN_LIBXML_VERSION options[:save_with] ||= save_option write_to io, options