Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
fix(codegen): choose the right quote for jsx attribute string (#4236)
  • Loading branch information
Boshen committed Jul 12, 2024
commit c65198fa152af560ced3fd2d8f88af1290612900
5 changes: 3 additions & 2 deletions crates/oxc_codegen/src/gen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2238,9 +2238,10 @@ impl<'a, const MINIFY: bool> Gen<MINIFY> for JSXAttributeValue<'a> {
Self::Fragment(fragment) => fragment.gen(p, ctx),
Self::Element(el) => el.gen(p, ctx),
Self::StringLiteral(lit) => {
p.print_char(b'"');
let quote = if lit.value.contains('"') { b'\'' } else { b'"' };
p.print_char(quote);
p.print_str(&lit.value);
p.print_char(b'"');
p.print_char(quote);
}
Self::ExpressionContainer(expr_container) => expr_container.gen(p, ctx),
}
Expand Down
3 changes: 1 addition & 2 deletions tasks/coverage/codegen_typescript.snap
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,4 @@ commit: d8086f14

codegen_typescript Summary:
AST Parsed : 5283/5283 (100.00%)
Positive Passed: 5282/5283 (99.98%)
Normal failed: "conformance/jsx/tsxReactEmitEntities.tsx"
Positive Passed: 5283/5283 (100.00%)