We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent f6cecec commit f13cdb4Copy full SHA for f13cdb4
2 files changed
lib/nokogiri/xml/node_set.rb
@@ -345,8 +345,9 @@ def to_html(*args)
345
args.insert(0, options)
346
end
347
if empty?
348
- encoding = (args.first.is_a?(Hash) ? args.first[:encoding] : nil) || document.encoding
349
- "".encode(encoding)
+ encoding = (args.first.is_a?(Hash) ? args.first[:encoding] : nil)
+ encoding ||= document.encoding
350
+ encoding.nil? ? "" : "".encode(encoding)
351
else
352
map { |x| x.to_html(*args) }.join
353
test/xml/test_node_set.rb
@@ -961,6 +961,12 @@ def awesome!; end
961
assert_equal(doc2, node_set[1].document)
962
963
964
+
965
+ describe "empty sets" do
966
+ it "#to_html returns an empty string" do
967
+ assert_equal("", NodeSet.new(xml, []).to_html)
968
+ end
969
970
971
972
0 commit comments