allow unsafe text in script

This commit is contained in:
Sara Vieira 2022-12-22 21:34:50 +00:00
parent 19af976dcb
commit 59fa2fd099
1 changed files with 16 additions and 1 deletions

View File

@ -311,7 +311,7 @@ declare_elements! {
src: Uri,
text: String,
type: String, // TODO could be an enum
} in [MetadataContent, FlowContent, PhrasingContent, TableColumnContent] with TextNode;
} in [MetadataContent, FlowContent, PhrasingContent, TableColumnContent] with PhrasingContent;
section in [FlowContent, SectioningContent] with FlowContent;
select {
autocomplete: String,
@ -488,3 +488,18 @@ fn test_aria() {
frag.to_string()
);
}
#[test]
fn test_js() {
use crate as axohtml;
use crate::{dom::DOMTree, html, text, unsafe_text};
let frag: DOMTree<String> = html!(<script>{unsafe_text!("console.log('{}')", "sup")}</script>);
let frag1: DOMTree<String> = html!(<script>{text!("console.log('{}')", "sup")}</script>);
assert_eq!("<script>console.log('sup')</script>", frag.to_string());
assert_eq!(
"<script>console.log(&#x27;sup&#x27;)</script>",
frag1.to_string()
);
}