Skip to content

Fix JSX parser to validate matching opening/closing tags#152

Merged
trueadm merged 6 commits intoRipple-TS:mainfrom
WebEferen:fix/opened-tags-mismatch
Sep 11, 2025
Merged

Fix JSX parser to validate matching opening/closing tags#152
trueadm merged 6 commits intoRipple-TS:mainfrom
WebEferen:fix/opened-tags-mismatch

Conversation

@WebEferen
Copy link
Copy Markdown
Collaborator

Overview

This PR fixes a critical bug in the Ripple compiler's JSX parser where unclosed and mismatched tags were silently accepted instead of throwing compilation errors.

Problem

Malformed JSX like <div></span> would compile successfully, potentially causing runtime issues

Solution

  • Added tag validation in parseTemplateBody() to ensure closing tags match their corresponding opening tags
  • Added validation to detect completely unclosed tags when parsing elements
    Implemented getElementName() helper to extract tag names from JSX nodes for comparison
  • Added comprehensive test cases for both mismatched tags (<div></span>) and unclosed tags (<div>content)

The compiler now throws descriptive errors:

  • Expected closing tag to match opening tag. Expected </div> but found </span>
  • Unclosed tag <div>. Expected </div> before end of component.

Referencing the issue #147

@vercel
Copy link
Copy Markdown

vercel bot commented Sep 11, 2025

@WebEferen is attempting to deploy a commit to the Ripple Team Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Sep 11, 2025

LiveCodes Preview in LiveCodes

Latest commit: d1ff54b
Last updated: Sep 11, 2025 3:43pm (UTC)

Playground Link
Ripple Playground: d1ff54b https://ripple.livecodes.pages.dev?x=code/N4Igxgrg...

See documentations for usage instructions.

Copy link
Copy Markdown
Collaborator

@trueadm trueadm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great, thank you!

Copy link
Copy Markdown
Collaborator

@trueadm trueadm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just realised some tests were failing.

@WebEferen
Copy link
Copy Markdown
Collaborator Author

WebEferen commented Sep 11, 2025

Looking at the tests, it was post merge so need to update them.
@trueadm feel free to check it out once again (post merge issues with missing })

@vercel
Copy link
Copy Markdown

vercel bot commented Sep 11, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
ripple Ready Ready Preview Comment Sep 11, 2025 4:55pm

Copy link
Copy Markdown
Collaborator

@trueadm trueadm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lgtm. Thank you!

@trueadm trueadm merged commit e0d271c into Ripple-TS:main Sep 11, 2025
10 checks passed
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.

2 participants