Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion native/html5ever_nif/src/flat_dom.rs
Original file line number Diff line number Diff line change
Expand Up @@ -583,7 +583,9 @@ pub fn flat_sink_to_rec_term<'a>(
NodeData::Text { contents } => {
term = StrTendrilWrapper(contents).encode(env);
}
NodeData::Comment { .. } => continue,
NodeData::Comment { contents } => {
term = (atoms::comment(), StrTendrilWrapper(contents)).encode(env);
}
_ => unimplemented!(""),
}

Expand Down
12 changes: 10 additions & 2 deletions test/html5ever_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,17 @@ defmodule Html5everTest do
end

test "parse basic html" do
html = "<html><head></head><body></body></html>"
html = "<html><head></head><body><h1>Hello</h1><!-- my comment --></body></html>"

assert Html5ever.parse(html) == {:ok, [{"html", [], [{"head", [], []}, {"body", [], []}]}]}
assert Html5ever.parse(html) ==
{:ok,
[
{"html", [],
[
{"head", [], []},
{"body", [], [{"h1", [], ["Hello"]}, {:comment, " my comment "}]}
]}
]}
end

test "does not parse with not valid UTF8 binary" do
Expand Down