-
-
Notifications
You must be signed in to change notification settings - Fork 905
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: serializing an individual attribute in an HTML5 document
Previously an exception would be raised, either "Unexpected node" or "Unsupported document node (2)" depending on the version of Nokogiri. Fixes #3125
- Loading branch information
1 parent
04ecb5b
commit 5ba752c
Showing
4 changed files
with
133 additions
and
90 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# frozen_string_literal: true | ||
|
||
require "helper" | ||
|
||
class TestHtml5Attributes < Nokogiri::TestCase | ||
def test_serialize_attribute | ||
html = <<~HTML | ||
<div id='foo' class="bar baz"></div> | ||
HTML | ||
div = Nokogiri::HTML5::DocumentFragment.parse(html).at_css("div") | ||
attrs = div.attribute_nodes | ||
id_attr = attrs.find { |a| a.name == "id" } | ||
class_attr = attrs.find { |a| a.name == "class" } | ||
|
||
assert_equal('id="foo"', id_attr.to_html) | ||
assert_equal('class="bar baz"', class_attr.to_html) | ||
end | ||
end if Nokogiri.uses_gumbo? |