Merge pull request #14 from axodotdev/allow_unsafe

allow unsafe text in script
This commit is contained in:
ashley williams 2022-12-23 10:54:18 -06:00 committed by GitHub
commit 03efe72dad
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 12 additions and 2 deletions

View File

@ -2,7 +2,7 @@
#![allow(non_camel_case_types)]
use crate::dom::{Node, TextNode};
use crate::dom::{Node, TextNode, UnsafeTextNode};
use crate::types::*;
use crate::OutputType;
use axohtml_macros::declare_elements;
@ -312,7 +312,7 @@ declare_elements! {
src: Uri,
text: String,
type: String, // TODO could be an enum
} in [MetadataContent, FlowContent, PhrasingContent, TableColumnContent, HTMLContent] with TextNode;
} in [MetadataContent, FlowContent, PhrasingContent, TableColumnContent, HTMLContent] with UnsafeTextNode;
section in [FlowContent, SectioningContent] with FlowContent;
select {
autocomplete: String,
@ -489,3 +489,13 @@ fn test_aria() {
frag.to_string()
);
}
#[test]
fn test_js() {
use crate as axohtml;
use crate::{dom::DOMTree, html, unsafe_text};
let frag: DOMTree<String> = html!(<script>{unsafe_text!("console.log('{}')", "sup")}</script>);
assert_eq!("<script>console.log('sup')</script>", frag.to_string());
}