diff --git a/Cargo.lock b/Cargo.lock index 75f72d16138..adbce4abbe2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3770,6 +3770,7 @@ version = "0.2.1" dependencies = [ "bitflags", "lexical", + "once_cell", "serde", "serde_json", "swc_atoms", diff --git a/crates/swc_html_ast/src/token.rs b/crates/swc_html_ast/src/token.rs index 17fff0e4a8a..b8a727f807a 100644 --- a/crates/swc_html_ast/src/token.rs +++ b/crates/swc_html_ast/src/token.rs @@ -35,6 +35,7 @@ pub enum Token { Comment { data: JsWord, }, + // TODO add `raw` to get real character from code Character { value: char, }, diff --git a/crates/swc_html_codegen/src/lib.rs b/crates/swc_html_codegen/src/lib.rs index 3e617555f14..ccbb6355f99 100644 --- a/crates/swc_html_codegen/src/lib.rs +++ b/crates/swc_html_codegen/src/lib.rs @@ -116,7 +116,7 @@ where start_tag.push('>'); - write_raw!(self, span, &start_tag); + write_str!(self, span, &start_tag); } Token::EndTag { tag_name, @@ -145,7 +145,7 @@ where start_tag.push('>'); - write_raw!(self, span, &start_tag); + write_str!(self, span, &start_tag); } Token::Comment { data } => { let mut comment = String::new(); diff --git a/crates/swc_html_codegen/tests/fixture/attributes/input.html b/crates/swc_html_codegen/tests/fixture/attributes/input.html index 0edbdc55f8b..014ccba86aa 100644 --- a/crates/swc_html_codegen/tests/fixture/attributes/input.html +++ b/crates/swc_html_codegen/tests/fixture/attributes/input.html @@ -8,5 +8,55 @@ + + +
x
+x
+ +x
+ + + + + + + +foo bar baz
+foo bar baz
+ + + +x
+x
+x
+xxx
+xxx
+xxx
+ +x
+x
+x
+Click me
+ + +