Escape HTML as we translate to rsx (#3038)

This commit is contained in:
Evan Almloff authored and GitHub committed 2024-10-08 07:02:02 -05:00
1 parent 9ffd4b816b
commit d64df87aba
4 files changed
+37 -1

No files matched your search

+18
View File
@@ -0,0 +1,18 @@
use html_parser::Dom;
// Regression test for https://github.com/DioxusLabs/dioxus/issues/3037
// We need to escape html entities as we translate html because rsx doesn't support them
#[test]
fn escaped_text() {
let html = r#"<div>&lt;div&gt;&#x231b;&#x231b;&#x231b;&#x231b;</div>"#.trim();
let dom = Dom::parse(html).unwrap();
let body = dioxus_rsx_rosetta::rsx_from_html(&dom);
let out = dioxus_autofmt::write_block_out(&body).unwrap();
let expected = r#"
div { "<div>⌛⌛⌛⌛" }"#;
pretty_assertions::assert_eq!(&out, &expected);
}