diff --git a/crates/swc_html_codegen/src/lib.rs b/crates/swc_html_codegen/src/lib.rs index 49cd14d8a7d..f1e7a50bba1 100644 --- a/crates/swc_html_codegen/src/lib.rs +++ b/crates/swc_html_codegen/src/lib.rs @@ -857,9 +857,9 @@ fn minify_attribute_value(value: &str) -> String { } if dq > sq { - format!("'{}'", minified) + format!("'{}'", minified.replace('\'', "'")) } else { - format!("\"{}\"", minified) + format!("\"{}\"", minified.replace('"', """)) } } diff --git a/crates/swc_html_codegen/tests/fixture/attribute/input.html b/crates/swc_html_codegen/tests/fixture/attribute/input.html index dc8909cae06..f571409a581 100644 --- a/crates/swc_html_codegen/tests/fixture/attribute/input.html +++ b/crates/swc_html_codegen/tests/fixture/attribute/input.html @@ -150,5 +150,32 @@ __ bind(&current); ø &osLash; Ø + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/crates/swc_html_codegen/tests/fixture/attribute/output.html b/crates/swc_html_codegen/tests/fixture/attribute/output.html index da11090cec3..8b9d35d73eb 100644 --- a/crates/swc_html_codegen/tests/fixture/attribute/output.html +++ b/crates/swc_html_codegen/tests/fixture/attribute/output.html @@ -146,6 +146,33 @@ __ bind(&current); ø &osLash; Ø + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/crates/swc_html_codegen/tests/fixture/attribute/output.min.html b/crates/swc_html_codegen/tests/fixture/attribute/output.min.html index 1d3a1d0e112..4bcd5b93db4 100644 --- a/crates/swc_html_codegen/tests/fixture/attribute/output.min.html +++ b/crates/swc_html_codegen/tests/fixture/attribute/output.min.html @@ -144,5 +144,32 @@ __ bind(&current); ø &osLash; Ø + + + + + + + + + + + + + + + + + + + + + + + + + + +