diff --git a/native/html5ever_nif/src/flat_dom.rs b/native/html5ever_nif/src/flat_dom.rs index e21aca8..d8f3adb 100644 --- a/native/html5ever_nif/src/flat_dom.rs +++ b/native/html5ever_nif/src/flat_dom.rs @@ -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!(""), } diff --git a/test/html5ever_test.exs b/test/html5ever_test.exs index 94151e4..00d0784 100644 --- a/test/html5ever_test.exs +++ b/test/html5ever_test.exs @@ -8,9 +8,17 @@ defmodule Html5everTest do end test "parse basic html" do - html = "" + html = "

Hello

" - 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