fix(jsx): multiline property value

closes #598
closes #569
This commit is contained in:
三咲智子 Kevin Deng 2023-06-25 16:52:38 +08:00
parent e434f78f6f
commit 8ed497de1d
No known key found for this signature in database
GPG Key ID: 69992F2250DFD93E
2 changed files with 2 additions and 2 deletions

View File

@ -36,7 +36,7 @@ const getJSXAttributeValue = (
return transformJSXElement(valuePath, state); return transformJSXElement(valuePath, state);
} }
if (valuePath.isStringLiteral()) { if (valuePath.isStringLiteral()) {
return valuePath.node; return transformJSXText(valuePath);
} }
if (valuePath.isJSXExpressionContainer()) { if (valuePath.isJSXExpressionContainer()) {
return transformJSXExpressionContainer(valuePath); return transformJSXExpressionContainer(valuePath);

View File

@ -138,7 +138,7 @@ export const getJSXAttributeName = (path: NodePath<t.JSXAttribute>): string => {
* @returns StringLiteral | null * @returns StringLiteral | null
*/ */
export const transformJSXText = ( export const transformJSXText = (
path: NodePath<t.JSXText> path: NodePath<t.JSXText | t.StringLiteral>
): t.StringLiteral | null => { ): t.StringLiteral | null => {
const { node } = path; const { node } = path;
const lines = node.value.split(/\r\n|\n|\r/); const lines = node.value.split(/\r\n|\n|\r/);