diff --git a/crates/swc_html_codegen/src/lib.rs b/crates/swc_html_codegen/src/lib.rs index a3a6cfde025..7d88a60cc6b 100644 --- a/crates/swc_html_codegen/src/lib.rs +++ b/crates/swc_html_codegen/src/lib.rs @@ -655,11 +655,9 @@ where attribute.push_str(&minifier); } else { - let quote = if value.contains('"') { '\'' } else { '"' }; + let normalized = normalize_attribute_value(value); - attribute.push(quote); - attribute.push_str(value); - attribute.push(quote); + attribute.push_str(&normalized); } } @@ -671,26 +669,16 @@ where if self.ctx.skip_escape_text { write_str!(self, n.span, &n.value); } else { - let mut data = String::new(); + let mut data = String::with_capacity(n.value.len()); if self.ctx.need_extra_newline_in_text && n.value.contains('\n') { data.push('\n'); } - for c in n.value.chars() { - match c { - '&' => { - data.push_str(&String::from("&")); - } - '<' => { - data.push_str(&String::from("<")); - } - '>' => { - data.push_str(&String::from(">")); - } - '\u{00A0}' => data.push_str(&String::from(" ")), - _ => data.push(c), - } + if self.config.minify { + data.push_str(&minify_text(&n.value)); + } else { + data.push_str(&escape_string(&n.value, false)); } write_str!(self, n.span, &data); @@ -699,7 +687,7 @@ where #[emitter] fn emit_comment(&mut self, n: &Comment) -> Result { - let mut comment = String::new(); + let mut comment = String::with_capacity(n.data.len() + 7); comment.push_str(" @@ -68,20 +68,20 @@
- + - + - + - - - - - - + + + + + + +test +test +test +test +test +test +Test +Test +Test +Test +Test +Test + +Label current;
+// Load effective address of current instruction into rcx.
+__ leaq(rcx, Operand(¤t));
+__ bind(¤t);
+
+
+