From be82c286d63f4660cde7df590a9586eec284232f Mon Sep 17 00:00:00 2001 From: Boshen <1430279+Boshen@users.noreply.github.com> Date: Fri, 12 Jul 2024 16:17:23 +0000 Subject: [PATCH] fix(codegen): print `JSXAttributeValue::StringLiteral` directly (#4231) jsx attribute string is interpreted as is without escaping. The transformer is responsible for converting it to plain js string. --- crates/oxc_codegen/src/gen.rs | 2 +- tasks/coverage/codegen_typescript.snap | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/crates/oxc_codegen/src/gen.rs b/crates/oxc_codegen/src/gen.rs index cc09bda3b378e..24a3ed87f64f2 100644 --- a/crates/oxc_codegen/src/gen.rs +++ b/crates/oxc_codegen/src/gen.rs @@ -2239,7 +2239,7 @@ impl<'a, const MINIFY: bool> Gen for JSXAttributeValue<'a> { Self::Element(el) => el.gen(p, ctx), Self::StringLiteral(lit) => { p.print_char(b'"'); - print_unquoted_str(&lit.value, b'"', p); + p.print_str(&lit.value); p.print_char(b'"'); } Self::ExpressionContainer(expr_container) => expr_container.gen(p, ctx), diff --git a/tasks/coverage/codegen_typescript.snap b/tasks/coverage/codegen_typescript.snap index 40c83a4c391d1..43ef9aaf1ae2f 100644 --- a/tasks/coverage/codegen_typescript.snap +++ b/tasks/coverage/codegen_typescript.snap @@ -2,7 +2,5 @@ commit: d8086f14 codegen_typescript Summary: AST Parsed : 5283/5283 (100.00%) -Positive Passed: 5280/5283 (99.94%) -Normal failed: "compiler/jsxMultilineAttributeStringValues.tsx" -Normal failed: "compiler/jsxMultilineAttributeValuesReact.tsx" +Positive Passed: 5282/5283 (99.98%) Normal failed: "conformance/jsx/tsxReactEmitEntities.tsx"