Repository navigation
fix(compat): decode character references in JSX text and attribute values, as @tsrx/core 0.5.2 does - #144
Merged
Conversation
…lues, as @tsrx/core 0.5.2 does (#111)
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Merged
9 of 10 tasks
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #111.
In
tsrx-core-compat, everyJSXTextand every stringJSXAttributenow gets the samevalueandrawthat@tsrx/core0.5.2 gives it:valuehas its character references decoded the way acorn-typescript'sjsx_readEntitydecodes them: a name from acorn-jsx's XHTML table, or&#…;/&#x…;/&#X…;up to U+10FFFF. It reads at most 10 characters after the&. Anything else stays as written:&bogus;,✓,&with no;,�, a bare&.rawstays as written.valuereads CRLF as LF andrawkeeps the CRLF. An attribute'svaluekeeps CRLF, as core's does.The decoding runs in the facade's existing final walk (
materializeCompatibilityProgram), and it is skipped when the source has no&and no\r. The Rust engine and the native parser, lint, format and printer output are unchanged. A test checks that the native parser still gives JSX strings as written.Verification. I compared against
@tsrx/[email protected], looking atvalueandrawfor every JSX text and string attribute:.tsxI added eight tests to
tests/parser-api/core-conformance.test.mjs, using core 0.5.2's values. The helper in the #118 test used to assert thatraw === value. It now reportsraw, because a text'svalueis decoded now.Note. As the issue says, Octane decodes these values itself until it reads them from
raw(octanejs/octane#1399, octanejs/octane#1330). Until those land, Octane's Node output decodes them twice.🤖 Generated with Claude Code
Note
Medium Risk
Post-parse AST mutation in the compat facade affects all consumers of decoded JSX
valuefields; behavior is gated on source content but mismatches with downstream double-decode (e.g. Octane) remain a integration risk.Overview
Fixes #111 by aligning
tsrx-core-compatwith @tsrx/core 0.5.2 for JSX string handling: decodedvalue, unchangedraw.During
materializeCompatibilityProgram, when the source contains&or\r, the facade walksJSXTextand stringJSXAttributenodes and decodes character references using acorn-jsx’s XHTML table and acorn-typescript-style rules (&#…;,&#x…;, 10-character limit, invalid refs left as text). JSX text also normalizes CRLF to LF invalue; attributes keep CRLF. Expression-container strings are untouched. The native/Rust parser path is unchanged; bundleddistoutputs mirror the source.Tests: eight #111 cases in
core-conformance.test.mjs; the #118 children helper now reportsrawinstead of assumingraw === value.Reviewed by Cursor Bugbot for commit 52c0586. Bugbot is set up for automated code reviews on this repo. Configure here.