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: JSX attribute parsing issue when using html entities #1234

Merged
merged 2 commits into from
Jun 22, 2022

Conversation

skovhus
Copy link
Contributor

@skovhus skovhus commented Apr 26, 2022

Issue: #1225

#1226 added support for handling quotes in JSX attributes. Turns out there are other cases related to this where the jsxAttribute string literal value should be wrapped in an jsxExpressionContainer:

<Trans>
  <Text>This should work &nbsp;</Text>
</Trans>

The case here fails in compilers such as ESBuild. This requires updated a lot of test expectations, but the change is not a breaking change.

@vercel
Copy link

vercel bot commented Apr 26, 2022

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated
js-lingui ❌ Failed (Inspect) Apr 26, 2022 at 0:31AM (UTC)

@codecov
Copy link

codecov bot commented Apr 26, 2022

Codecov Report

Merging #1234 (386c75b) into main (2a235ba) will decrease coverage by 0.01%.
The diff coverage is n/a.

@@            Coverage Diff             @@
##             main    #1234      +/-   ##
==========================================
- Coverage   81.69%   81.68%   -0.02%     
==========================================
  Files          56       56              
  Lines        1770     1769       -1     
  Branches      491      490       -1     
==========================================
- Hits         1446     1445       -1     
  Misses        194      194              
  Partials      130      130              
Impacted Files Coverage Δ
packages/macro/src/macroJsx.ts 91.30% <ø> (-0.07%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 88252d7...386c75b. Read the comment docs.

@skovhus skovhus changed the title fix: html entities fix: JSX attribute parsing issue when using html entities Apr 26, 2022
@skovhus
Copy link
Contributor Author

skovhus commented May 10, 2022

@semoal the size testing check failure seems unrelated.

@skovhus
Copy link
Contributor Author

skovhus commented Jun 13, 2022

@semoal let me know if there is anything I can do to land this.

@semoal
Copy link
Contributor

semoal commented Jun 22, 2022

@semoal let me know if there is anything I can do to land this.

As far as I see in the tests, now it's impossible to just use:

<Trans id="Hello World" /> with this pr, will be mandatory use brackets?

@skovhus
Copy link
Contributor Author

skovhus commented Jun 22, 2022

with this pr, will be mandatory use brackets?

No you can still do that. Note that it is just all the expected output that are updated – not the test input.

There should be a jsxExpressionContainer (i.e. brackets) in order to support cases like:

<Trans>
  <Text>This should work &nbsp;</Text>
</Trans>

@semoal semoal merged commit 98e9332 into lingui:main Jun 22, 2022
@skovhus skovhus deleted the ks/fix-html-entities branch June 22, 2022 13:58
@skovhus
Copy link
Contributor Author

skovhus commented Jun 22, 2022

Let me know if there is anything needed before releasing this. Thanks!

@semoal
Copy link
Contributor

semoal commented Jun 22, 2022

Let me know if there is anything needed before releasing this. Thanks!

Just released 3.14.0 :)

divyansh7924 pushed a commit to divyansh7924/js-lingui that referenced this pull request Oct 5, 2022
* Handle html entities in macro

* Update test expectations
@dahei
Copy link

dahei commented Mar 31, 2023

I stumbled over that problem while migrating our project from Webpack to Vite (which uses esbuild). Upgrade to 3.17.2 make it work 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants