Skip to content

Commit

Permalink
fix: handle pre tag jsx parent parens
Browse files Browse the repository at this point in the history
Closes #425
  • Loading branch information
dsherret committed Sep 12, 2022
1 parent 40e848e commit 543a610
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 12 deletions.
24 changes: 12 additions & 12 deletions src/generation/generate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3452,19 +3452,19 @@ fn gen_jsx_element<'a>(node: &'a JSXElement, context: &mut Context<'a>) -> Print
let in_between_range = SourceRange::new(node.opening.end(), closing.start());
items.extend(ir_helpers::gen_from_raw_string_trim_line_ends(in_between_range.text_fast(context.program)));
items.extend(gen_node(closing.into(), context));
return items;
items
} else {
let result = gen_jsx_with_opening_and_closing(
GenJsxWithOpeningAndClosingOptions {
opening_element: node.opening.into(),
closing_element: closing.into(),
children: node.children.iter().map(|x| x.into()).collect(),
},
context,
);
context.store_info_range_for_node(node, (result.start_ln, result.end_ln));
result.items
}

let result = gen_jsx_with_opening_and_closing(
GenJsxWithOpeningAndClosingOptions {
opening_element: node.opening.into(),
closing_element: closing.into(),
children: node.children.iter().map(|x| x.into()).collect(),
},
context,
);
context.store_info_range_for_node(node, (result.start_ln, result.end_ln));
result.items
} else {
let start_ln = LineNumber::new("jsxElementStart");
let end_ln = LineNumber::new("jsxElementEnd");
Expand Down
30 changes: 30 additions & 0 deletions tests/specs/issues/issue0425.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
~~ deno: true ~~
== should handle parens wrapping in pre tags ==
function Example() {
return (
<pre>
Hello
</pre>
);
}
function Example() {
return <pre>
Hello
</pre>;
}

[expect]
function Example() {
return (
<pre>
Hello
</pre>
);
}
function Example() {
return (
<pre>
Hello
</pre>
);
}

0 comments on commit 543a610

Please sign in to comment.