Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(compiler): avoid escape non-English character #29124

Closed
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -1276,6 +1276,7 @@ const createJsxText = withLoc(t.jsxText);
const createJsxClosingElement = withLoc(t.jsxClosingElement);
const createJsxOpeningElement = withLoc(t.jsxOpeningElement);
const createStringLiteral = withLoc(t.stringLiteral);
const createTemplateElement = withLoc(t.templateElement);

function createHookGuard(
guard: ExternalFunction,
Expand Down Expand Up @@ -2042,6 +2043,20 @@ function codegenJsxAttribute(
value = innerValue;
if (value.value.indexOf('"') !== -1) {
value = createJsxExpressionContainer(value.loc, value);
} else {
// workaround for babel behavior that will escape StringLiteral value
value = createTemplateLiteral(
value.loc,
[
createTemplateElement(
value.loc,
{ raw: value.value, cooked: value.value },
true
),
],
[]
);
value = createJsxExpressionContainer(value.loc, value);
}
break;
}
Expand Down
Loading