-
-
Notifications
You must be signed in to change notification settings - Fork 903
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 (#3127)
**What problem is this PR intended to solve?** Previously an exception would be raised, either "Unexpected node" or "Unsupported document node (2)" depending on the version of Nokogiri. Fixes #3125 **Have you included adequate test coverage?** Yes. **Does this change affect the behavior of either the C or the Java implementations?** HTML5 is only available in CRuby.
- Loading branch information
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? |